1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 double data1, data2; 6 char op; 7 while (3 == scanf("%lf%c%lf", &data1, &op, &data2) ) 8 { 9 double result; 10 printf("%lf%c%lf=", data1,data2); 11 switch (op) 12 { 13 case ‘+‘: 14 result = data1 + data2; 15 break; 16 case ‘-‘: 17 result = data1 - data2; 18 break; 19 case ‘*‘: 20 result = data1 * data2; 21 break; 22 case ‘/‘: 23 result = data1 / data2; 24 break; 25 default:; 26 } 27 printf("%lf\n", result); 28 } 29 30 return 0; 31 }
时间: 2024-10-14 06:46:10