本文共 1555 字,大约阅读时间需要 5 分钟。
one + two =three four + five six =zero seven + eight nine =zero + zero =
39096
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 18 19 #define MAXD 99999999 20 using namespace std; 21 22 23 24 map mp; 25 26 27 28 29 30 int main() 31 { 32 33 mp["zero"]=0; 34 mp["one"]=1; 35 mp["two"]=2; 36 mp["three"]=3; 37 mp["four"]=4; 38 mp["five"]=5; 39 mp["six"]=6; 40 mp["seven"]=7; 41 mp["eight"]=8; 42 mp["nine"]=9; 43 44 int i,j,k; 45 int n; 46 47 48 char s[1000]; 49 50 51 while(gets(s)) 52 { 53 int a,b; 54 55 56 i=0; 57 58 59 int temp=0; 60 61 while(s[i]!='+') 62 { 63 string ts=""; 64 65 while(s[i]!=' ') 66 { 67 68 69 ts+=s[i]; 70 i++; 71 } 72 73 temp*=10; 74 temp+=mp[ts]; 75 i++; 76 } 77 78 79 80 a=temp; 81 82 83 84 85 temp=0; 86 87 88 89 90 i++; 91 i++; 92 93 94 while(s[i]!='=') 95 { 96 97 string ts=""; 98 99 while(s[i]!=' ')100 {101 102 103 104 105 ts+=s[i];106 107 i++;108 }109 110 111 temp*=10;112 temp+=mp[ts];113 i++;114 }115 116 117 b=temp;118 119 120 121 int c=a+b;122 123 if(c==0)124 break;125 else126 cout< <
转载于:https://www.cnblogs.com/zjushuiping/archive/2012/05/30/2526793.html