一道简单的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...e
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 22:13:16
一道简单的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...e
一道简单的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
一道简单的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...e
#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;
}
这样应该对了,不过你再找我