123456789101112131415161718192021222324252627 |
- #include <stdio.h>
- int main() {
- int data1,data2;
- char op;
- scanf("%d %d %c",&data1,&data2,&op);
-
- switch(op) {
- case '+':
- printf("%d\n",data1 + data2);
- break;
- case '-':
- printf("%d\n",data1 - data2);
- break;
- case '*':
- printf("%d\n",data1 * data2);
- break;
- case '/':
- if(data2 != 0) {
- float result = (float) data1 / data2;
- printf("%.3g\n",result);
- }
- break;
- }
-
- return 0;
- }
|