1005. Spell It Right (20)
来源:互联网 发布:淘宝分享有礼在哪里 编辑:程序博客网 时间:2024/06/08 19:27
- 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:
12345
Sample Output:
one five
#include <bits/stdc++.h>using namespace std;int main(){ char ma[12345]; long long int sum = 0; scanf("%s", ma); if(ma[0]=='0') cout<<"zero"<<endl; else{ for(int i=0; ma[i]; i++) { sum = sum + ma[i] - '0'; } int k[12345]; int top = -1; while(sum) { int a = sum % 10; k[++top] = a; sum /= 10; } int flag = 1; for(int i=top; i>=0; i--) { if(flag!=1) { printf(" "); } else { flag = 0; } if(k[i]==1)printf("one"); else if(k[i]==2)printf("two"); else if(k[i]==3)printf("three"); else if(k[i]==4)printf("four"); else if(k[i]==5)printf("five"); else if(k[i]==6)printf("six"); else if(k[i]==7)printf("seven"); else if(k[i]==8)printf("eight"); else if(k[i]==9)printf("nine"); else if(k[i]==0)printf("zero"); } cout<<endl; } 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)
- Caffe编译问题"locale::facet::_S_create_c_locale name not valid"
- win10下TortoiseSVN 1.9.7-x64不显示图标
- Qt软件发布问题记录
- 在android studio导入应用原码出现的error: protocol fault (couldn't read status): Connection reset by peer
- 修改限值 scada系统
- 1005. Spell It Right (20)
- 本地服务器安装 GITLAB 服务
- python 求两个数列的交集、并集与差集
- 唯快不破:TCP/IP详解--TCP/IP连接各个状态转换分析
- 程序员面试的那些百分百原则,你会了吗?
- python 执行命令
- 【语言转换】matlab regionprops方法 参数为area IDL实现
- seller.avatar 报错 avatar of undefined
- 响应式布局基本实现Media Query(媒介查询)