Description
读入两个小于100的正整数A和B,计算A+B.
需要注意的是:A和B的每一位数字由对应的英文单词给出.
需要注意的是:A和B的每一位数字由对应的英文单词给出.
Input
测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B =",相邻两字符串有一个空格间隔.当A和B同时为0时输入结束,相应的结果不要输出.
Output
对每个测试用例输出1行,即A+B的值.
Sample Input
one + two =
three four + five six =
zero seven + eight nine =
zero + zero =
three four + five six =
zero seven + eight nine =
zero + zero =
Sample Output
3
90
96
90
96
考虑好空格和加数的位数就可以了
#include<bits/stdc++.h>
#define one 1
#define two 2
#define three 3
#define four 4
#define five 5
#define six 6
#define seven 7
#define eight 8
#define nine 9
#define zero 0
using namespace std;
char a[];
int i=;
int t=;
int num[];
int con=;
int flag=;
int main()
{ while(scanf("%c",&a[i])){
if(a[i]>='a'&&a[i]<='z')
{
con++;
i++;
}
else if(a[i]=='+') {i++;flag =t;}
else if(a[i]!='=')
{ if(con==)
{
if(a[i-]=='o'&&a[i-]=='n') num[t++]=;
else if(a[i-]=='t'&&a[i-]=='w') num[t++]=;
else if(a[i-]=='s') num[t++]=;
}
else if(con==)
{
if(a[i-]=='u') num[t++]=;
else if(a[i-]=='v') num[t++]=;
else if(a[i-]=='n') num[t++]=;
else if(a[i-]=='r') num[t++]=;
}
else if(con==)
{
if(a[i-]=='e') num[t++]=;
else if(a[i-]=='n') num[t++]=;
else if(a[i-]=='t') num[t++]=;
}
con=;
i++;
}
else if(a[i]=='=')
{
if(num[]==num[]&&num[]==) return ;
if(t==) cout<<num[]+num[]<<endl;
else if(t==&&flag==) cout<<num[]*+num[]+num[]<<endl;
else if(t==&&flag==) cout<<num[]+num[]*+num[]<<endl;
else cout<<num[]*+num[]+num[]*+num[]<<endl;
memset(a,NULL,sizeof(a));
i=;
con=;
memset(num,NULL,sizeof(num));
t=;
flag=;
} }
}