rendered paste body#include <stdio.h>
#include <conio.h>
struct TComplex
{
float coef_real;
float coef_img;
};
int citeste(struct TComplex *z)
{
printf("Dati coeficientul real\n");
fflush(stdin);
scanf("%f",z->coef_real);
printf("Dati coeficientul imaginar\n");
scanf("%f",z->coef_img);
return 0;
}
int scrie(struct TComplex z)
{
printf("Numarul complex citit este:%f + (%fi)", z.coef_real, z.coef_img);
return 0;
}
int aduna(struct TComplex z1, struct TComplex z2, struct TComplex *rez)
{
rez->coef_real=z1.coef_real + z2.coef_real;
rez->coef_img=z1.coef_img + z2.coef_img;
return 0;
}
int inmultire(struct TComplex z1, struct TComplex z2, struct TComplex *rez)
{
rez->coef_real=(z1.coef_real*z2.coef_real) + ((-1)*(z1.coef_img*z2.coef_img));
rez->coef_img=(z1.coef_real*z2.coef_img)+(z1.coef_img*z2.coef_real);
return 0;
}
void main()
{
struct TComplex c1,c2,ad,in;
citeste(&c1);
citeste(&c2);
scrie(c1);
scrie(c2);
aduna(c1,c2,&ad);
inmultire(c1,c2,&in);
scrie(ad);
scrie(in);
getch();
}