http://acm.nyist.net/JudgeOnline/problem.php?pid=128&前缀式计算
来源:互联网 发布:无壳鸡蛋孵小鸡知乎 编辑:程序博客网 时间:2024/06/04 06:05
istringstream对象可以绑定一行字符串,然后以空格为分隔符把该行分隔开来。
#include<iostream>#include<sstream>using namespace std;int main(){string str, line;while(getline(cin, line)){istringstream stream(line);while(stream>>str)cout<<str.c_str()<<endl;}return 0;}
#include<iostream>#include<cstring>#include<sstream>#include<string> #include<cstdio>using namespace std;char s[505];double exc(istringstream &iss){ char a[10]; double res; iss>>a;cout<<a<<endl; switch(a[0]) { case '+':return exc(iss)+exc(iss);break; case '-':return exc(iss)-exc(iss);break; case '*':return exc(iss)*exc(iss);break; case '/':return exc(iss)/exc(iss);break; default :sscanf(a,"%lf",&res); return res; }}int main(){ double result; while(gets(s)) { istringstream iss(s); result=exc(iss); cout.precision(2); cout<<fixed<<result<<endl; } return 0;}
- http://acm.nyist.net/JudgeOnline/problem.php?pid=128&前缀式计算
- http://acm.nyist.net/JudgeOnline/problem.php?pid=128&&前缀式计算
- http://acm.nyist.net/JudgeOnline/problem.php?pid=290
- http://acm.nyist.net/JudgeOnline/problem.php?pid=434
- http://acm.nyist.net/JudgeOnline/problem.php?pid=13
- http://acm.nyist.net/JudgeOnline/problem.php?pid=239
- http://acm.nyist.net/JudgeOnline/problem.php?pid=129
- http://acm.nyist.net/JudgeOnline/problem.php?pid=431
- http://acm.nyist.net/JudgeOnline/problem.php?pid=301
- http://acm.nyist.net/JudgeOnline/problem.php?pid=451
- http://acm.nyist.net/JudgeOnline/problem.php?pid=459
- http://acm.nyist.net/JudgeOnline/problem.php?pid=20
- http://acm.nyist.net/JudgeOnline/problem.php?pid=267
- http://acm.nyist.net/JudgeOnline/problem.php?pid=305
- http://acm.nyist.net/JudgeOnline/problem.php?pid=309
- http://acm.nyist.net/JudgeOnline/problem.php?pid=325
- http://acm.nyist.net/JudgeOnline/problem.php?pid=420
- http://acm.nyist.net/JudgeOnline/problem.php?pid=488
- sqlserver 存储过程备份
- 报错纠正
- firefox中点击新建标签页打开主页
- 三步搞定ANDROID应用图片缓存
- 从ibatis到mybatis
- http://acm.nyist.net/JudgeOnline/problem.php?pid=128&前缀式计算
- UI的转变:向美学的迈进
- RubyGem nokogiri failed to install – libxslt is missing – Error installing nokogiri
- Lucene 介绍
- #ifdef的用法
- dbutils中的MapListHandler()返回列顺序不对!
- ffmpeg开发指南
- CArchive类
- tld 算法移植到arm开发板(6410) (二)