P - A + B(第二季水)
Description
Input
Output
Sample Input
Sample Output
#include <iostream>
#include <string>
using namespace std;
int g(string str)
{
if(str=="zero")return ;
if(str=="one")return ;
if(str=="two")return ;
if(str=="three")return ;
if(str=="four")return ;
if(str=="five")return ;
if(str=="six")return ;
if(str=="seven")return ;
if(str=="eight")return ;
if(str=="nine")return ;
}
int main()
{
string a[];
while(cin>>a[]>>a[]>>a[]){
int i,k1,k2;
for(i=;;i++){
cin>>a[i];
if(a[i]=="=")break;
}
if(a[]=="zero"&&a[]=="+"&&a[]=="zero"&&a[]=="=")break;
if(a[]=="+"){
k1=g(a[]);
if(a[]=="=")k2=g(a[]);
else k2=g(a[])*+g(a[]);
}
else{
k1=*g(a[])+g(a[]);
if(a[]=="=")k2=g(a[]);
else k2=g(a[])*+g(a[]);
}
cout<<k1+k2<<endl;
}
//system("pause");
return ;
}
依旧灵活使用字符串即可
P - A + B(第二季水)的更多相关文章
- F - The Fun Number System(第二季水)
Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...
- D - Counterfeit Dollar(第二季水)
Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...
- S - 骨牌铺方格(第二季水)
Description 在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...
- R - 一只小蜜蜂...(第二季水)
Description 有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数. 其中,蜂房的结构如下所示. ...
- I - Long Distance Racing(第二季水)
Description Bessie is training for her next race by running on a path that includes hills so that sh ...
- Y - Design T-Shirt(第二季水)
Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...
- N - Robot Motion(第二季水)
Description A robot has been programmed to follow the instructions in its path. Instructions for the ...
- B - Maya Calendar(第二季水)
Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old ...
- T - 阿牛的EOF牛肉串(第二季水)
Description 今年的ACM暑期集训队一共有18人,分为6支队伍.其中有一个叫做EOF的队伍,由04级的阿牛.XC以及05级的COY组成.在共同的集训生活中,大家建立了深厚的 ...
- E - Number Sequence(第二季水)
Description A single positive integer i is given. Write a program to find the digit located in the p ...
随机推荐
- 判断两个View的GRect是否相等
if (CGRectEqualToRect(self.view.frame, rect)) { // do some stuff }
- [转]PictureEx.h和PictureEx.cpp源文件
要显示一个gif,网上找了个,子类化了MFCl图片控件,用着方便,记一下 转自:http://www.bccn.net/Article/net/vcnet/jszl/200709/6386.html ...
- js的原型继承小结
考虑:有一个想要复用的对象,并且想要创建的第二个对象需要从第一个对对象中获取其功能. 实现如下: //要继承的对象 var parent = { name:"Papa" }; // ...
- Windows10 磁盘活动时间百分之百导致系统卡顿解决方法
最近电脑边的特别慢,打开任务管理器发现是磁盘活动时间时不时的就会变成100%.起初是以为硬盘出问题了,后来网上查了一下才发现很多人都遇到过这个问题,其原因就是Windows的SuperFetch和家庭 ...
- php在cli和cgi方式下获取服务器ip的实例
php cli方式下获取服务器ip php内核没有提供这样的命令,需要借助linux中的命令ifconfig来实现,如下两个函数代码: function getServerIp(){ ...
- 用php逐行读取文件
做个备份年纪大了,都不愿意自己思考了 $str = file_get_contents($tmpfilename);//获得内容 $arr = explode("\n",$str) ...
- postgresql配置的一些问题
ubuntu通过软件中心安装后,配置文件位于如下目录 我用超级用户创建了其它数据库用户,发现是登录不了的,必须还得创建同名的linux用户,甚是麻烦.在配置文件pg_hba.conf中发现了问题. 其 ...
- mysql innodb_double_write特性
知识储备: 1.mysql 的crasy recovery 是通过redo log 和undo log 来完成的: 2.redo log 和undo log的记录的是对页面的物理操作:如在1024号p ...
- 添加事件监听兼容IE6-8
IE8一下浏览器不支持addEventListener,用attachEvent取而代之,但是在时间类型前面要加上’on‘,例如click时间在attachEvent中要写成onclick. var ...
- mongodb操作记录
[User]1.db.addUser("name","pwd","true/false")2.db.auth("name" ...