mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
59 lines
1021 B
C
59 lines
1021 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef struct
|
|
{
|
|
double L,R;
|
|
}INUM;
|
|
char str[1024];
|
|
char* format(INUM i)
|
|
{
|
|
sprintf(str,"(%.2f%+.2fi)",i.L,i.R);
|
|
return str;
|
|
}
|
|
int main()
|
|
{
|
|
INUM a,b;
|
|
scanf("%lf %lf %lf %lf",&a.L,&a.R,&b.L,&b.R);
|
|
INUM ans;
|
|
ans.L=a.L+b.L;
|
|
ans.R=a.R+b.R;
|
|
printf(format(a));
|
|
printf("+");
|
|
printf(format(b));
|
|
printf("=");
|
|
printf(format(ans));
|
|
printf("\n");
|
|
|
|
ans.L=a.L-b.L;
|
|
ans.R=a.R-b.R;
|
|
printf(format(a));
|
|
printf("-");
|
|
printf(format(b));
|
|
printf("=");
|
|
printf(format(ans));
|
|
printf("\n");
|
|
|
|
ans.L=a.L*b.L-a.R*b.R;
|
|
ans.R=a.L*b.R+a.R*b.L;
|
|
printf(format(a));
|
|
printf("*");
|
|
printf(format(b));
|
|
printf("=");
|
|
printf(format(ans));
|
|
printf("\n");
|
|
|
|
ans.L=a.L*b.L+a.R*b.R;
|
|
ans.L/=b.L*b.L+b.R*b.R;
|
|
ans.R=a.R*b.L-a.L*b.R;
|
|
ans.R/=b.L*b.L+b.R*b.R;
|
|
printf(format(a));
|
|
printf("/");
|
|
printf(format(b));
|
|
printf("=");
|
|
printf(format(ans));
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|