国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

PAT A 1005. Spell It Right (20)

2019-11-08 01:42:00
字體:
來源:轉載
供稿:網友

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:
12345Sample Output:
one five
// 題目分析:
字符串數組存儲字符串常量
// 代碼
#include <iostream>#include <string>#include <vector>using namespace std;int main(){	char a[110];	string strs[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};	scanf("%s",a);	int i=0;	int sum=0;	while(a[i]!='/0'){		sum+=a[i]-'0';		i++;	}	vector<int> v;	while(sum!=0){		v.push_back(sum%10);		sum/=10;	}	for(int i=v.size()-1;i>0;i--){		cout<<strs[v[i]]<<' ';	}	if(v.empty()){		cout<<"zero";	}else{		cout<<strs[v[0]];	}	system("pause");	return 0;}
//結果
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 玉山县| 昌黎县| 济源市| 曲松县| 乌审旗| 汉中市| 重庆市| 佳木斯市| 双辽市| 阿拉尔市| 象州县| 昆山市| 休宁县| 巩义市| 磴口县| 三江| 志丹县| 长治县| 深水埗区| 康定县| 莆田市| 齐河县| 涿州市| 陇川县| 涟水县| 辰溪县| 神池县| 上杭县| 特克斯县| 德州市| 郑州市| 北安市| 缙云县| 新邵县| 西昌市| 遵化市| 炎陵县| 正定县| 年辖:市辖区| 乡城县| 建水县|