PAT甲级真题及训练集(15)--1005. Spell It Right (20)
来源:互联网 发布:我的世界手机java版 编辑:程序博客网 时间:2024/06/07 16:38
1005. Spell It Right (20)
时间限制
400 ms
内存限制
65536 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
提交代码
/**作者:一叶扁舟时间:16:33 2017/7/1思路:*/#include <stdlib.h>#include <stdio.h>#include <string.h>#define SIZE 11100int main(){int sum = 0;char digit[10][20] = {"zero","one","two","three","four","five","six","seven","eight","nine"};char inputNum[SIZE];int result[SIZE];int count = 0;scanf("%s", inputNum);for (int i = strlen(inputNum) - 1; i >= 0; i--){int temp = inputNum[i] - '0';sum += temp;}do{int temp = sum % 10;result[count] = temp;count++;sum = sum / 10;} while (sum != 0);//输出for (int i = count - 1; i >= 0; i--){printf("%s",digit[result[i]]);if (i != 0){printf(" ");}}system("pause");return 0;}
阅读全文
0 0
- PAT甲级真题及训练集(15)--1005. Spell It Right (20)
- 1005. Spell It Right (20)-PAT甲级真题
- PAT - 甲级 - 1005. Spell It Right (20)
- PAT甲级.1005. Spell It Right (20)
- 【PAT甲级】1005. Spell It Right (20)
- PAT甲级1005. Spell It Right (20)
- PAT甲级 1005. Spell It Right (20)
- PAT甲级1005. Spell It Right (20)
- PAT 甲级 1005. Spell It Right (20)
- PAT甲级1005. Spell It Right
- PAT 甲级 1005. Spell It Right
- [PAT-甲级]1005.Spell It Right
- PAT甲级1005. Spell It Right
- PAT 甲级 1005. Spell It Right
- 【PAT甲级】【C++】1005. Spell It Right (20)
- PAT TEST 甲级1005. Spell It Right (20)
- PAT(甲级)1005. Spell It Right (20)
- PAT甲级练习1005. Spell It Right (20)
- 在 Laravel 的 Blade 模版中定义变量
- centos 下修改用户密码
- halcon学习笔记——Image,region,xld初步
- [leetcode]628. Maximum Product of Three Numbers
- 最小的K个数
- PAT甲级真题及训练集(15)--1005. Spell It Right (20)
- 欢迎使用CSDN-markdown编辑器
- 小程序开发系列(八)利用SQL实现access_token的自动通知
- Python机器学习应用 | 基于聚类的“图像分割”
- vc平台下将数组里的数据画成曲线
- JS模式中总结的知识点
- qq下方图标
- 2.JSR简介
- 500 line or less 这本神奇的书,它有20个左右不到500行代码的Python项目,能够写出很牛逼的项目,但是感觉不适合新手,可以用来进阶