Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) |
#include "iostream"
#include "stdio.h"
#include "math.h"
#include "vector"
#include "queue"
#include "memory.h"
#include "algorithm"
#include "string"
using namespace std;
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
int Num(char *str,int *i)
{
int tmp;
switch(str[(*i)])
{
case 'z':
tmp=0;break;
case 'o':
tmp= 1;break;
case 't':
if(str[(*i)+1]=='w') tmp= 2;
if(str[(*i)+1]=='h') tmp= 3;
if(str[(*i)+1]=='e') tmp= 10;break;
case 'f':
if(str[(*i)+1]=='o')tmp= 4;
if(str[(*i)+1]=='i')tmp= 5;break;
case 's':
if(str[(*i)+1]=='i')tmp= 6;
if(str[(*i)+1]=='e')tmp= 7;break;
case 'e':
tmp= 8;break;
case 'n' :
tmp= 9;break;
}
while(str[++(*i)]!=' ');
return tmp;
}
int Trans(char *str,int s,int e)
{
int x=0,i=s,blankpos=-1,tmp;
while(str[i]==' ')
i++;
tmp=Num(str,&i);
while((str[i]==' '||str[i]=='=')&&i<=e)
i++;
if(i<e)
{
tmp*=10;
tmp+=Num(str,&i);
}
return tmp;
}
int main()
{
int x;
char exp[40],num1[20],num2[20];
while(gets(exp))
{
int i,j;
for(i=0;i<strlen(exp);i++)
{
if(exp[i]=='+')
break;
}
int x1=Trans(exp,0,i-1);
int x2=Trans(exp,i+1,strlen(exp)-1);
if(!x1&&!x2)
break;
printf("%d\n",x1+x2);
}
}