标签:case Right int sum Spell contains 1005 include line
题目描述:
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 (≤).
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
问题分析:此题过于弱智,没有思路,干就完了,奥里给!
代码:
1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 using namespace std; 5 6 const string x[10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; 7 8 int main(){ 9 char ch[101]; 10 int a[101],l,sum=0; 11 cin.getline(ch,102); 12 for (int i=0;i<=100;i++){ 13 if (isdigit(ch[i])){ 14 sum+=ch[i]-'0'; 15 } 16 else{ 17 break; 18 } 19 } 20 for (int i=0;;i++){ 21 a[i]=sum % 10; 22 sum/=10; 23 if (sum==0){ 24 l=i+1; 25 break; 26 } 27 } 28 for (int i=l-1;i>0;i--){ 29 cout << x[a[i]] << " "; 30 } 31 cout << x[a[0]]; 32 return 0; 33 }
标签:case,Right,int,sum,Spell,contains,1005,include,line 来源: https://www.cnblogs.com/jarvis-yang/p/12372934.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。