mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-23 21:58:41 +00:00
25 lines
480 B
C
25 lines
480 B
C
#include <stdio.h>
|
|
|
|
int main() {
|
|
int a, b;
|
|
char op;
|
|
|
|
scanf("%d %c %d", &a, &op, &b);
|
|
|
|
if (op == '+') {
|
|
printf("%d\n", a + b);
|
|
} else if (op == '-') {
|
|
printf("%d\n", a - b);
|
|
} else if (op == '*') {
|
|
printf("%d\n", a * b);
|
|
} else if (op == '/' && b != 0) {
|
|
printf("%.2lf\n", (double)a / b);
|
|
} else if (op == '%' && b != 0) {
|
|
printf("%d\n", a % b);
|
|
} else {
|
|
printf("Error\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|