PAT 1005
来源:互联网 发布:java windows换行符 编辑:程序博客网 时间:2024/06/13 15:42
1005. Spell It Right (20)
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 <stack>#include <string.h>using namespace std;#define max 100char input[max];int main(){stack<int> s;int i,t,len,sum=0; cin>>input;len=strlen(input);for(i=0;i<len;i++){t=input[i]-'0';sum+=t;}while(sum/10!=0)//sum>10{t=sum%10;//个位sum=sum/10;s.push(t);//入栈}s.push(sum);while(!s.empty()){t=s.top();s.pop();if(t==1){cout<<"one";}if(t==2){cout<<"two";}if(t==3){cout<<"three";}if(t==4){cout<<"four";}if(t==5){cout<<"five";}if(t==6){cout<<"six";}if(t==7){cout<<"seven";}if(t==8){cout<<"eight";}if(t==9){cout<<"nine";}if(t==0){cout<<"zero";}if(!s.empty()){cout<<" ";}else{cout<<endl;}} return 0;}
1 0
- pat 1005
- PAT 1005
- PAT 1005
- pat 1005
- PAT 1005
- PAT 1005
- PAT 1005
- PAT 1005
- PAT 1005
- PAT 1005
- PAT Basic 1005
- PAT Advanced 1005
- 浙江大学pat 1005
- PAT (Basic) 1001~1005
- PAT Basic Practice 1005
- PAT(A) 1005
- PAT Basic 1005
- PAT Advanced 1005
- light OJ 1140
- (p169)构建二叉搜索树和进行相应的操作
- Sql数据库查询语言
- Android 操作系统的内存回收机制
- tomcat一直处于deploying状态。
- PAT 1005
- 关于php线程安全的一些东西
- 蓝桥杯 历届试题 饮料换购
- 最坏情况为线性时间的选择算法
- NYOJ——题目44:子串和
- 最短路径—Dijkstra算法和Floyd算法
- Android内存管理原理
- java中 i++ 与 ++i
- nyoj801 哈夫曼编码,输入有毒