1005. Spell It Right
来源:互联网 发布:网络韩语翻译兼职 编辑:程序博客网 时间:2024/06/09 13:31
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.
#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 110int Change (char c);void Draw (char a);int main (){ long sum=0; char num[N]; gets(num); int i; for( i=0;i<strlen(num);i++) { sum+=Change(num[i]); } char str[N]; sprintf(str,"%d",sum); for( i=0;i<strlen(str)-1;i++) { Draw(str[i]); printf(" "); } Draw(str[i]); printf("\n"); system("pause"); return 0; }void Draw (char a){ switch (a) { case '0':printf("zero");return; case '1':printf("one");return; case '2':printf("two");return; case '3':printf("three");return; case '4':printf("four");return; case '5':printf("five");return; case '6':printf("six");return; case '7':printf("seven");return; case '8':printf("eight");return; case '9':printf("nine");return; } }int Change (char c){ return c-'0'; }
0 0
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005.Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 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)
- pat 1005. Spell It Right
- 分布式与集群的区别
- android 5.0 播放音乐时闹钟响,此时来电话并挂断,闹钟和音乐同时响
- java得到IP地址的一些方法
- Android Message和obtainMessage的区别
- android国际化(values对应文件夹)
- 1005. Spell It Right
- 协议和委托个人理解+++++++++++++++++
- 选择相册中的图片,并获取图片的path
- mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid1 ended
- 写一个c程序判断大小端
- s标签显示后台数据的基本用法以及iterator遍历用法
- CodeForces 257C View Angle
- ssm整合2(详细教程)
- VIM 常用操作