1005 Spell It Right (20point(s)) Easy only once
作者:互联网
基本思想:
弱智题,没啥可说的;
关键点:
无;
#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; }
标签:std,seven,Right,int,sum,Spell,only,using,include 来源: https://www.cnblogs.com/songlinxuan/p/12200486.html