国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}
//結果
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桃江县| 上林县| 康保县| 沂南县| 邯郸县| 抚顺县| 扬中市| 台东县| 鄂托克旗| 西乡县| 肥东县| 天柱县| 泸西县| 新巴尔虎左旗| 奈曼旗| 诸城市| 蒲城县| 襄城县| 隆回县| 林口县| 青田县| 通辽市| 克东县| 格尔木市| 禹城市| 西峡县| 宜良县| 皮山县| 金华市| 长沙县| 阿坝县| 金昌市| 广汉市| 民丰县| 双峰县| 阿城市| 天长市| 平度市| 邵阳县| 松江区| 烟台市|