1005. Spell It Right (20)
来源:互联网 发布:json解析框架 编辑:程序博客网 时间:2024/06/08 19:25
PAT
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:
12345
Sample Output:
one five
输入一串字符,加和后用英文输出每一位
代码
#include<cstdio>#include<cstring>using namespace std;int main(){ char c[10][20]={"zero","one","two","three", "four","five","six","seven","eight","nine"}; char a[100],b[100]; scanf("%s",a); int sum=0; for(int i=0;i<strlen(a);i++)//加和 sum+=a[i]-'0'; sprintf(b,"%d",sum);//字符串和整型互换 printf("%s",c[b[0]-'0']);//输出第一位 for(int i=1;i<strlen(b);i++) printf(" %s",c[b[i]-'0']); return 0; }
0 0
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- C语言动态创建二维数组代码
- Android内存优化大全(上)
- Bootstrap网格系统
- NSIS安装程序完成后运行某程序或某函数
- 项目代码优化(三)
- 1005. Spell It Right (20)
- 转动态数组的使用
- 小项目第三天
- windows安装redis MySQL-python相关方法
- JS原型、原型链深入理解
- HTTP解读-文件下载、中文乱码、请求重定向、定时刷新、缓存、url编解码、gzip压缩、防盗链等
- 计算机组成原理试卷二(期末复习备用)
- 在windows平台搭建基于nginx的直播服务器
- oracle根据时间修改 date