Create 1765.c

This commit is contained in:
Kirigaya Kazuto 2016-06-28 14:22:18 +08:00 committed by GitHub
parent 2142b21b9c
commit 0496e70793

58
QUSTOJ/1765.c Normal file
View File

@ -0,0 +1,58 @@
#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;
}