水题一道,难度在于怎么精简代码
#include <stdio.h>
int n, a, b;
char ch;
float c;
int main(void) {
scanf("%d", &n);
while(n--) {
getchar();//读取换行
ch = getchar();
scanf("%d%d", &a, &b);
switch(ch) {
case '+' : printf("%d\n", a+b); break;
case '-' : printf("%d\n", a-b); break;
case '*' : printf("%d\n", a*b); break;
case '/' : a%b==0 ? printf("%d\n", a/b) : printf("%.2f\n", (float)(a*1.0/b));
}
}
return 0;
}