标签: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