一战时的中国:那个可以编一个运算器给我啊要用IF语言编啊

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/09 14:50:29
#include <stdio.h>
main()
{
float x,y;
char op;
printf("z:") ;
scanf("%f%c%f",&x,&op,&y) ;
if (op=='+')
printf("%d%c%d=%.2f",x,op,y,x+y);
if(op=='-')
printf("%d%c%d=%.2f",x,op,y,x-y) ;
if(op=='*')
printf("%d%c%d=%.2f",x,op,y,x*y) ;
if(op=='/')
printf("%d%c%d=.2f",x,op,y,x/y);
printf("%d%c%d=.2f",x+y,x-y,x*y,x/y) ;
}
 那错啦怎么改啊
你可以编一个给我吗?

input a,b
input a$
if a$="+" then print a+b
if a$="-" then if a>b then print a-b else print b-a
if a$="*" then print a*b
if a$="/" then if a>b then print a/b else print b/a

C ?????????
晕啊 为什么不用c#哦

你的输出格式为%d,表示输出为整数,如果人输入的时候有小数的话结果就会有问题哦!试试全部改成%f吧!