/*********************************
* 日期:2012-6-28
* 作者:SJF0115
* 题号: 九度1010
* 题目:A + B
* 结果:AC
* 题意:
* 总结:
**********************************/
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int ToNumber(string A)
{
if(A=="one")
return 1;
else if(A=="two")
return 2;
else if(A=="three")
return 3;
else if(A=="four")
return 4;
else if(A=="five")
return 5;
else if(A=="six")
return 6;
else if(A=="seven")
return 7;
else if(A=="eight")
return 8;
else if(A=="nine")
return 9;
else if(A=="zero")
return 0;
else
return -1;
}
int main()
{
string num[1000];
int i = 0;
//输入重定向,输入数据将从in.txt文件中读取
//freopen("C:\\Users\\SJF\\Desktop\\in.txt","r",stdin);
while(cin>>num[i])
{
int num1 = 0,num2 = 0;
//遇到等号停止输入
if(num[i] != "="){
i++;
continue;
}
int j = 0;
while(num[j] != "+"){
num1 = num1 * 10 + ToNumber(num[j]);
j++;
}
while(++j<i){
num2 = num2 * 10 + ToNumber(num[j]);
}
i = 0;
if(num1 == 0 && num2 == 0){
break;
}
printf("%d\n",num1 + num2);
}
return 0;
}
九度1010 A + B
最新推荐文章于 2019-02-07 12:38:44 发布