Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.
Input Specification:
Each input file contains one test case. Each case occupies one line which contains an N (<= 10100).
Output Specification:
For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.
Sample Input:
12345
Sample Output:
one five
参考代码:
#include <iostream>
#include <string.h>
using namespace std;
string map[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
int main()
{
string num,result = "";
int sum = 0;
cin>>num;
for(int i=0;i<num.length();i++){
sum += num[i]-48;
}
if(sum == 0){
cout<<map[sum]<<endl;
return 0;
}
while(sum>0){ //To change a integer to a string
result = map[sum%10]+" "+result;
sum /= 10;
}
string s = result.substr(0,result.length()-1);
cout<<s<<endl;
return 0;
}
简单水过!
分享到:
相关推荐
1005 Spell It Right (20 分)【int与string互换,hash打表】 1082 Read Number in Chinese (25 分)【将数字转成中文】 1093 Count PAT's (25 分)【PAT计数】 1071 Speech Patterns (25 分)【如何将词...
Improve the Quality of Your Documentation: Spell-check XML documentation comments in your code as you type, right in Visual Studio. It’s Easy: Identify misspelled words in an entire solution with ...
Improve the Quality of Your Documentation: Spell-check XML documentation comments in your code as you type, right in Visual Studio. It’s Easy: Identify misspelled words in an entire solution with ...
” Twenty-six years later I am still working on it and hope to get it right one of these days. Back then my dream device was something I could slip into my pocket, pull out when needed, and aim it at ...
Natural Language Processing is used everywhere—in search engines, spell checkers, mobile phones, computer games, and even in your washing machine. Python's Natural Language Toolkit (NLTK) suite of ...
6 , chunks.zip This will open a file and read it in "Chunks" of a selected file.<END><br>7 , logging.zip This is a bas that will log installation procedures so the file can be removed later....
- With Delphi XE2 or XE3 it is possible to compile WPTools into a 64 bit applications. You need WPTools 6 PRO or WPTools 6 Premium for this. - Localization and Inch/CM selection see ...
It offers key features like multi-lingual keyword searching, faceted search, intelligent matching, and relevancy weighting right out of the box. Solr in Action is the definitive guide to implementing...
This open source tools makes it easier to internationalize .NET application into many ... This tool makes use of .NET version 3.5 because it uses a new text control that allows for spell checking.
It offers key features like multi-lingual keyword searching, faceted search, intelligent matching, and relevancy weighting right out of the box. Solr in Action is the definitive guide to implementing...
The benefit of a column maker is that it can help you to format your text/code, or in some cases to make it easier to read in complex nested logic. Quick Open UltraEdit and UEStudio provide multiple ...
(case=5567, case=7457) 6027, 6021 Listboxes are positioned such that they are not truncated at the right edge of the screen. (case=5178) Listbox remains on the same side of a symbol (either ...