码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-01-16 12:15:18      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:spel   system   main   class   begin   pac   iostream   col   cin   

基本思想:

弱智题,没啥可说的;

 

关键点:

无;

 

#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

标签:spel   system   main   class   begin   pac   iostream   col   cin   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!