1005.Spell It Right (20)
来源:互联网 发布:深圳勘察研究院知乎 编辑:程序博客网 时间:2024/06/04 18:52
1005.Spell It Right (20)
pat-al-1005
2017-01-24
- 零的时候特殊处理一下,不知道有没有测试点测这个
- 用字符串二维数组保存要输出的英文
/** * pat-al-1005 * 2017-01-25 * C version * Author: fengLian_s */#include<stdio.h>#include<string.h>int main(){ freopen("in.txt", "r", stdin); char str[102]; scanf("%s", str); int sum = 0; for(int k = 0;k < strlen(str);k++) { //printf("str[%d] = %c\n", k, str[k]); sum += str[k] - '0'; } int num[10]; if(sum == 0) { printf("zero\n"); return 0; } int i = 0; while(sum) { num[i++] = sum % 10;//常常写while的时候忘了写成i++,就会段错误 sum /= 10; } char num2English[10][10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; printf("%s", num2English[num[--i]]); for(i = i-1;i >= 0;i--) { printf(" %s", num2English[num[i]]); } putchar('\n'); return 0;}
-FIN-
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)
- 37-2-book
- Java&Android调试方法
- Codeforces 762 A.k-th divisor (简单有关因子的问题)
- HMM的Baum-Welch算法和Viterbi算法公式推导细节
- HDU2046 骨牌铺方格
- 1005.Spell It Right (20)
- 1008.Elevator (20)
- Linux kernel 分析之二十一:定时器-巧妙的定时器算法
- 1011.World Cup Betting (20)
- 字串统计——蓝桥杯
- c++中的string常用函数用法总结
- 4+1VIEW 软件系统视角模型
- 【hdu 1112】The Proper Key
- hdu 2089 不要62 数位dp