一道简单的acm习题,为什么我的程序没有输出?

问题描述:

一道简单的acm习题,为什么我的程序没有输出?
The contest starts now!How excited it is to see balloons floating around.You,one of the best programmers in HDU,can get a very beautiful balloon if only you have solved the very very very...easy problem.
Give you an operator (+,-,*,/ --denoting addition,subtraction,multiplication,division respectively) and two positive integers,your task is to output the result.
Is it very easy?
Come on,guy!PLMM will send you a beautiful Balloon right now!
Good Luck!
Input
Input contains multiple test cases.The first line of the input is a single integer T (0
1个回答 分类:英语 2014-11-21

问题解答:

我来补答
#include
#include
#include
int main()
{
char ch;
int n, x, y;
scanf("%d", &n);//1
while(n--)
{
getchar(); //这里是接收1处的回车的
ch = getchar();//getchar ()是这样用的
scanf("%d %d",&x, &y);
switch (ch) //switch 可以用char型的
{
case '+':
printf("%d\n", x + y);
break;
case '-':
printf("%d\n", x - y);
break;
case '*':
printf("%d\n", x * y);
break;
case '/':
printf("%.2f\n", (float)(x / y));
break;
default:
break;
}
}
return 0;
}
这样应该对了,不过你再找我
 
 
展开全文阅读
剩余:2000
上一页:减术分裂
下一页:语文学习与巩固