【PAT (Advanced Level)】1005. Spell It Right (20)
来源:互联网 发布:c string数组添加元素 编辑:程序博客网 时间:2024/06/06 03:18
1005. Spell It Right (20)
时间限制
400 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
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
代码:
/************************************This is a test program for anythingEnjoy IT!************************************/#include <iostream>#include <iomanip>#include <algorithm>#include <vector>#include <list>#include <set>#include <fstream>#include <string>#include <cmath>using namespace std;int main(){/*ifstream cin;cin.open("in.txt");ofstream cout;cout.open("out.txt");*///////////////////////////////////////////////////////////////////////////// TO DO Whatever You WANT!string s1;while (cin >> s1 ){int sum = 0;list<string> out;for (int i = 0; i < s1.length(); i++){sum += s1[i] - '0';}do {switch (sum % 10){case 0:out.push_front("zero");break;case 1:out.push_front("one");break;case 2:out.push_front("two");break;case 3:out.push_front("three");break;case 4:out.push_front("four");break;case 5:out.push_front("five");break;case 6:out.push_front("six");break;case 7:out.push_front("seven");break;case 8:out.push_front("eight");break;case 9:out.push_front("nine");break;}sum /= 10;} while (sum != 0);int len = out.size();for (int i = 0; i < len; i++){if (i == 0){cout << out.front();}else{cout << " " << out.front();}out.pop_front();}cout << endl;}//////////////////////////////////////////////////////////////////////////// system("pause");return 0;}
0 0
- PAT(Advanced level) 1005. Spell It Right
- 【PAT Advanced Level】1005. Spell It Right (20)
- 【c++】PAT (Advanced Level) 1005. Spell It Right (20)
- 【PAT (Advanced Level)】1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1005. Spell It Right (20)
- PAT (Advanced Level) 1005. Spell It Right (20) 解题报告
- PAT (Advanced Level) Practise 1005. Spell It Right (20)
- PAT (Advanced Level) 1005. Spell It Right (20)
- 【PAT】【Advanced Level】1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1005. Spell It Right (20)
- PAT Advanced Level 1005:Spell It Right
- PAT (Advanced) 1005. Spell It Right (20)
- [PAT (Advanced Level) ]1005. Spell It Right解题文档
- 浙大 PAT Advanced level 1005. Spell It Right
- PAT (Advanced Level) Practise 1005 Spell It Right (20)
- PAT-PAT (Advanced Level) Practise 1005. Spell It Right (20) (简单模拟题)【一星级】
- 1005. Spell It Right (20)——PAT (Advanced Level) Practise
- PAT (Advanced Level) 1005. Spell It Right (20) string转int,哈希
- IOS APP切图相关
- Vmware Workstation增加硬盘空间
- java Socket通信(一)
- UCGUI几个基本消息总结
- HDFS2.0 HA完整配置过程
- 【PAT (Advanced Level)】1005. Spell It Right (20)
- 输入一个字节内的数(0-255)和移动位数.输出移位结果(要求循环移位)
- 常用数据库的特点、应用场景信息整理
- 导热系数/热阻测试--美信检测
- (高德地图)MapView出不来界面
- java Socket(二)
- MFC控件编程:Tab Control
- 关联容器
- 数据结构栈的数组实现初始化,入栈,出栈,获取栈顶元素,栈的长度等操作