- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
static /vars/global/animals/cat;
/pub//demo/foo(int /args/mouse)
{
int /vars/local/animals/dog;
return /vars/local/animals/dog =
/vars/global/animals/cat + /args/mouse;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 3
+147
static /vars/global/animals/cat;
/pub//demo/foo(int /args/mouse)
{
int /vars/local/animals/dog;
return /vars/local/animals/dog =
/vars/global/animals/cat + /args/mouse;
}
как вам такой код?)
+147
#include <math.h>
#include <iostream>
#include <conio.h>
#include <istream>
using namespace std;
class Complex{
public:
double real;
double image;
Complex(){};
Complex(double re){real = re; image = 0;}
Complex(double re, double im){real = re ; image = im ;}
~Complex(){}
Complex & operator=(Complex &);
Complex & operator=(double);
double abs(){
return sqrt(real * real + image * image);
}
double arg(){
return (2*atan(image/(real+abs())));
}
double imag(){
return image;
}
double re(){
return real;
}
inline friend Complex operator+(const Complex, const Complex);
Complex operator+();
inline friend Complex operator-(const Complex, const Complex);
inline friend Complex operator*(const Complex, const Complex);
inline friend Complex operator*(Complex, double);
inline friend Complex operator/(const Complex, const Complex);
inline friend Complex operator/(const Complex, const double);
inline friend Complex operator+=(Complex, Complex);
inline friend Complex operator+=(Complex, double);
inline Complex conj(Complex fp1);
inline Complex Complex::expon(Complex fp1);
inline Complex Complex::sinus(Complex fp1);
inline Complex Complex::cosinus(Complex fp1);
inline Complex Complex::hypercosinus(Complex fp1);
inline Complex Complex::hypersinus(Complex fp1);
inline Complex Complex::logarithm(Complex fp1);
friend ostream &operator<<(ostream &, Complex &);
friend istream &operator>>(istream &, Complex &);
};
const Complex _i = Complex(0,1);
Complex Complex::operator+()
{
return *this;
}
Complex operator+(const Complex fp1, const Complex fp2)
{
Complex fp;
fp.real = fp1.real + fp2.real;
fp.image = fp1.image + fp2.image;
return fp;
}
Complex operator+=(Complex fp1, Complex fp2)
{
fp1.real = fp1.real + fp2.real;
fp1.image = fp1.image + fp2.image;
return fp1;
}
Complex operator+=(Complex fp1, double dbl)
{
fp1.real = fp1.real + dbl;
return fp1;
}
Complex operator-(const Complex fp1, const Complex fp2)
{
Complex fp;
fp.real = fp1.real - fp2.real;
fp.image = fp1.image - fp2.image;
return fp;
}
Complex operator*(const Complex fp1, const Complex fp2)
{
Complex fp;
fp.real = fp1.real * fp2.real - fp1.image * fp2.image;
fp.image = fp1.real * fp2.image + fp1.image * fp2.real;
return fp;
}
Complex operator*(Complex fp1, double dbl)
{
fp1.real = dbl * fp1.real;
fp1.image = dbl * fp1.image;
return fp1;
}
Complex operator/(const Complex fp1, const Complex fp2)
{
double k;
Complex fp;
лаба по ИВТ.. класс для работы с комплексными числами
+148
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
#include <string.h>
#include <io.h>
#include <fcntl.h>
struct student {
char FIO[40];
char Group[10];
int TaoN;
char Ball[3];
}qt,st,zt,*zap;
int flen(char * fname){
int handle, len;
handle = open(fname,O_RDWR);
len = filelength(handle);
close(handle);
return len;
}
void writte(FILE *f){
int ret;
printf("\t\t\tЗАПОЛНЕНИЕ БАЗЫ:\n\n");
printf("ФИО:\t\t");
scanf("%s", &st.FIO);
printf("ГРУППА:\t\t");
scanf("%s", &st.Group);
printf("НОМЕР ЗАЧЕТКИ:\t");
scanf("%d", &st.TaoN);
printf("БАЛЛ:\t\t");
scanf("%s", &st.Ball);
ret = atoi(st.Ball);
for(;;)
if((ret != 1) && (ret != 2) && (ret != 3) && (ret != 4) && (ret != 5)){
printf("Неверный символ. Введите число\n");
printf("БАЛЛ:\t\t");
scanf("%s", &st.Ball);
ret = atoi(st.Ball);
}
else break;
f = fopen("data.txt","a+");
fwrite(&st, sizeof(st), 1, f);
fclose(f);
};
void readd(student st,FILE *f){
int len,i,n;
system("cls");
printf("\t\t\tЧТЕНИЕ БАЗЫ:\n\n");
f = fopen("data.txt","r+");
len = flen("data.txt");
n = len/sizeof(st);
for(i = 0; i < n; i++)
{
fread(&st, sizeof(st), 1, f);
printf("ФИО:\t\t%s\n", st.FIO);
printf("ГРУППА:\t\t%s\n", st.Group);
printf("ЗАЧЕТКА:\t%d\n", st.TaoN);
printf("БАЛЛ:\t\t%d\n", st.Ball);
printf("\n");
}
}
void Searc(student zt,student st,FILE *f){
int len, n, i;
system("cls");
printf("\t\t\tПОИСК В БАЗЕ:\n\n");
printf("ФИО: ");
scanf("%s", &zt.FIO);
printf("\n");
if (strlen(zt.FIO) != 0){
f = fopen("data.txt","r+");
len = flen("data.txt");
n = len/sizeof(st);
for(i = 0; i < n; i++){
fread(&st, sizeof(st), 1, f);
int rt = strcmp(st.FIO, zt.FIO);
if (rt == 0)
{
printf("ФИО: ");
printf("\t\t%s\n", st.FIO);
printf("ГРУППА: ");
printf("\t%s\n", st.Group);
printf("ЗАЧЕТКА: ");
printf("\t%d\n", st.TaoN);
printf("БАЛЛ: ");
printf("\t\t%d\n", st.Ball,"\n");
}
}