A + B HDU1228

版权声明:菜鸟一枚~~ 有想法可在下面评论, 转载标明出处即可。 https://blog.csdn.net/KLFTESPACE/article/details/87707526
#include<iostream>
#include<cstdio>
#include <string.h>
#include<algorithm>
#include <map>

using namespace std;

string num[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};

int main()
{
    string s;
    int a=0, b=0;
    while(cin >> s){
        if(s == "+"){
            b = a;
            a = 0;
            continue;
        }
        if(s == "="){
            if(a == 0 && b == 0){
                break;
            }
            cout << a+b << endl;
            a = 0;
            b = 0;
        }
        for(int i=0; i<10; i++){
            if(s == num[i]){
                a = a*10+i;
            }
        }
    }




    return 0;
}

猜你喜欢

转载自blog.csdn.net/KLFTESPACE/article/details/87707526