标签:des style blog io ar color os sp for
59*684/-3*+#
57
1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<algorithm> 5 #include<stack> 6 using namespace std; 7 8 int main() 9 { 10 stack<int>q; 11 int i, t=0, f=0, len; 12 char s[10000]; 13 scanf("%s", s); 14 len = strlen(s); 15 for(i=0; i<len; i++) 16 { 17 if(s[i]==‘#‘) 18 { 19 printf("%d\n", q.top()); 20 break; 21 } 22 if(s[i]>=‘0‘ && s[i]<=‘9‘) 23 { 24 t = s[i]-‘0‘; 25 q.push(t); 26 } 27 else 28 { 29 f = q.top(); 30 q.pop(); 31 t = q.top(); 32 q.pop(); 33 if(s[i]==‘+‘) 34 t = t+f; 35 if(s[i]==‘-‘) 36 t = t-f; 37 if(s[i]==‘*‘) 38 t = t*f; 39 if(s[i]==‘/‘) 40 t = t/f; 41 q.push(t); 42 } 43 } 44 return 0; 45 }
标签:des style blog io ar color os sp for
原文地址:http://www.cnblogs.com/6bing/p/4126093.html