标签:
Description
Input
Output
Sample Input
Sample Output
#include <stdio.h> #include<string.h> int main() { int t,l ;double sum;double num[200]; while(scanf("%d",&t)) { l=0; sum = t*1.0; char c;if(t==0&&(c = getchar())==‘\n‘)return 0; while((c = getchar())!=‘\n‘) { if(c==‘*‘) { scanf("%d",&t);sum*=t;} //算出含*的值 if(c==‘/‘) { scanf("%d",&t);sum/=t*1.0;} // 算出含/的值 if(c==‘+‘) { num[l++] =sum; scanf("%d",&t);sum = t*1.0; //把sum存入数组 } if(c == ‘-‘) { num[l++] = sum; scanf("%d",&t);sum = -t*1.0;//把sum存入数组 } } num[l++] = sum; double sun = 0; for(int i = 0; i < l;i++) 对sum求和 算出表达式的值 sun += num[i]; printf("%.2lf\n",sun); } }
标签:
原文地址:http://www.cnblogs.com/LIUWEI123/p/5676803.html