标签:
Description
Input
Output
Sample Input
Sample Output
1 #include "cstdio" 2 void mset(double a[]) 3 { 4 for (int i=0;i<405;i++) 5 a[i] = 0; 6 } 7 int main() 8 { 9 double a[405]; 10 double sum; 11 int flag,i; 12 int m; 13 char c; 14 while (1) 15 { 16 mset(a); 17 i=0; 18 flag=0; 19 scanf ("%lf",&a[0]); 20 while (getchar() != ‘\n‘) 21 { 22 sum=0; 23 flag =1; 24 scanf ("%c %d",&c,&m); 25 switch (c) 26 { 27 case ‘+‘ : a[++i] = m; break; 28 case ‘-‘ : a[++i] = -m; break; 29 case ‘*‘ : a[i] = a[i]*m; break; 30 case ‘/‘ : a[i] = a[i]/m * 1.0; break; 31 } 32 } 33 if (!flag) 34 break; 35 for (int j=0;j<=i+1;j++) 36 sum+=a[j]; 37 printf ("%.2lf\n",sum); 38 } 39 return 0; 40 }
暑假集训(1)第六弹 -----简单计算器(Hdoj1237)
标签:
原文地址:http://www.cnblogs.com/huas-zlw/p/5676936.html