文章
28
粉丝
230
获赞
23
访问
244.2k
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
double n1,n2,x1,x2;
char op;
scanf("%lf %lf %lf %lf %c",&n1,&x1,&n2,&x2,&op);//查缺补漏:对于double的输入要用%lf
switch (op){
case '+' : add(n1,x1,n2,x2);break ;
case '*' : mul(n1,x1,n2,x2);break ;
}
return 0;
}
void add(double N1 , double X1 ,double N2,double X2){
printf("%.1f %.1f",N1+N2 ,X1+X2 );
}
void mul(double N1 , double X1 ,double N2,double X2){
double NewN;
double NewX;
NewN = N1*N2 - X1*X2;
NewX = N1*X2 + N2*X1;
printf("%.1f %.1f",NewN,NewX);//小数点后一位 %.1f
}
登录后发布评论
暂无评论,来抢沙发