mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1765.c
This commit is contained in:
parent
2142b21b9c
commit
0496e70793
58
QUSTOJ/1765.c
Normal file
58
QUSTOJ/1765.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user