1913: 小火山的计算能力
2016-08-10 19:23
806 查看
1913: 小火山的计算能力
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 444 Solved: 107
SubmitStatusWeb
Board
Description
别人说小火山的计算能力不行,小火山很生气,于是他想证明自己,现在有一个表达式,他想计算出来。Input
首先是一个t(1<=20)表示测试组数。然后一个表达式,表达式长度不超过200,只有加法和减法,并且保证第一个字符不会是运算符号,最终结果小于2^63-1。Output
输出运算结果。Sample Input
21+1
2+1-1
Sample Output
22
HINT
Source
zzuli模拟队列
#include<cstdio> #include<cstring> #include<queue> #include<algorithm> using namespace std; int main() { long long a; char s[210]; int t; scanf("%d",&t); while(t--) { scanf("%s",&s); int l=strlen(s); queue<long long>q1; queue<char>q2; for(int i=0;i<l;) { a=0; while(s[i]>='0'&&s[i]<='9') { a=a*10+s[i]-'0'; i++; } q1.push(a); if(i<l) { q2.push(s[i]); i++; } } long long sum,aa;char bb; sum=q1.front();q1.pop(); while(!q2.empty()) { aa=q1.front();q1.pop(); bb=q2.front();q2.pop(); if(bb=='+') sum+=aa; else sum-=aa; } printf("%lld\n",sum); } return 0; }
相关文章推荐
- 【zzulioj 1913 小火山的计算能力】
- ZZULIOJ 1913: 小火山的计算能力(栈模拟)
- ZZULIOJ-1913-小火山的计算能力(模拟)
- zzulioj 1913: 小火山的计算能力
- zzulioj1913 小火山的计算能力 (字符串)
- 1913: 小火山的计算能力
- zzulioj 1913 小火山的计算能力
- zzuliOJ 1913:小火山的计算能力(栈+水题)
- zzuli-1913: 小火山的计算能力
- ZZULI-1913 小火山的计算能力 【模拟加减】
- ZZULIOJ/郑轻OJ 1913 小火山的计算能力(模拟,水题)
- zzulioj1913: 小火山的计算能力
- zzuli OJ 1913: 小火山的计算能力 【水题】
- zzuli 1913: 小火山的计算能力(简单字符串处理 + 加减求和)
- ZZULIOJ (1913: 小火山的计算能力)
- 【zzuli-oj】-1913: 小火山的计算能力(计算器,水)
- ZZULIOJ 1913: 小火山的计算能力
- 【zzuliOJ】1913 - 小火山的计算能力(模拟)
- ZZULI-oj-1913 小火山的计算能力 ( 模拟 )
- zzulioj-1913-小火山的计算能力【数字字符加减模板】