PTA 1005 Spell It Right
2024-09-03 10:17:50
题目描述:
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
问题分析:此题过于弱智,没有思路,干就完了,奥里给!
代码:
#include <iostream>
#include <cstring>
#include <string>
using namespace std; const string x[]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int main(){
char ch[];
int a[],l,sum=;
cin.getline(ch,);
for (int i=;i<=;i++){
if (isdigit(ch[i])){
sum+=ch[i]-'';
}
else{
break;
}
}
for (int i=;;i++){
a[i]=sum % ;
sum/=;
if (sum==){
l=i+;
break;
}
}
for (int i=l-;i>;i--){
cout << x[a[i]] << " ";
}
cout << x[a[]];
return ;
}
最新文章
- 【转】Python练习,网络爬虫框架Scrapy
- 深入理解JS的delete
- Struts2上传大小限制
- win32下的双缓冲绘图技术
- angular+bootstrap+MVC 之二,模态窗
- CSS3实现旋转的太极图(二):只用1个DIV
- [转]面向GPU的多LOD因子的大规模场景可视化策略
- Java-日期转换
- C# 跨线程访问或者设置UI线程控件的方法
- 13.熟悉JDK的配置,环境变量
- linux打开文件数量的查看方法
- 会话标识未更新(AppScan扫描结果)
- AE 栅格处理
- 2015-10-15 晴 APUE GIT
- JMeter之Throughput Controller详解(实验)
- 开源项目——小Q聊天机器人V1.2
- 当 “HTTP” 先生遇上“S”小姐
- 《JAVA程序设计》_第九周学习总结
- Git合并不同url的项目
- 关于maven环境变量的配置问题