首页 > 其他 > 详细

1005 Spell It Right (20point(s)) Easy only once

时间:2020-01-16 12:34:56      阅读:55      评论:0      收藏:0      [点我收藏+]

基本思想:

弱智题,没啥可说的;

 

关键点:

无;

 

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector> 
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
using std::vector;

vector<string>eng = { "zero","one","two","three","four","five","six","seven","eight","nine" };
vector<int>vec;
int main() {
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
        sum += s[i] - 0;
    }
    if (sum == 0) {
        cout << eng[0] << endl;
        return 0;
    }
    else {
        while (sum!=0){
            vec.push_back(sum%10);
            sum /= 10;
        }
    }
    reverse(vec.begin(), vec.end());
    for (int i = 0; i < vec.size(); i++) {
        if (i == 0)
            printf("%s", eng[vec[i]].c_str());
        else {
            printf(" %s", eng[vec[i]].c_str());
        }
    }
    system("pause");
    return 0;
}

1005 Spell It Right (20point(s)) Easy only once

原文:https://www.cnblogs.com/songlinxuan/p/12200486.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!