logo

Bài tập về số phức


#include #include class Complex { public: Complex (int th=0,int a=0) //constructor { thuc=th; ao=a; } void Print() //ham xuat so phuc { if(thuc==0) { printf("%di",ao); } else { if(ao>0) { printf("%d+%di",thuc,ao); } else if(ao { Complex z(x.thuc+y.thuc,-x.ao-y.ao); return z; } int main() { Complex x(0,-3),y(4,5); x.Print();printf("\n"); y.Print();printf("\n"); Complex z; z=x+y; //tinh tong z.Print();printf("\n"); z=x-y; //tinh tong z.Print();printf("\n"); z=x*y; //tinh tich z.Print();printf("\n"); getch(); return 0; }
DMCA.com Protection Status Copyright by webtailieu.net