From 0496e70793e5611f5135fb221fb7208d1dbe26e4 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Tue, 28 Jun 2016 14:22:18 +0800 Subject: [PATCH] Create 1765.c --- QUSTOJ/1765.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 QUSTOJ/1765.c diff --git a/QUSTOJ/1765.c b/QUSTOJ/1765.c new file mode 100644 index 0000000..4ff7ab4 --- /dev/null +++ b/QUSTOJ/1765.c @@ -0,0 +1,58 @@ +#include +#include + +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; +}