算术入门之加减乘除
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int a = 0; 6 int b = 0; 7 8 scanf_s("%d %d", &a, &b); 9 10 printf("%d + %d = %d\n", a, b, a + b); 11 printf("%d - %d = %d\n", a, b, a - b); 12 printf("%d * %d = %d\n", a, b, a * b); 13 14 if (a % b == 0) 15 { 16 printf("%d / %d = %d", a, b, a / b); 17 } 18 else 19 { 20 printf("%d / %d = %.2f", a, b, a * 1.0 / b); 21 } 22 23 return 0; 24 }