07-0. 写出这个数 (20)
来源:互联网 发布:淘宝小类目让我发财了 编辑:程序博客网 时间:2024/05/20 02:27
读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。
输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10100。
输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格。
输入样例:1234567890987654321123456789输出样例:
yi san wu#include<stdio.h>#include<string.h>int main(){char ch, str[10][10];int sum = 0, n = 0;for (scanf("%c", &ch); ch != '\n'; scanf("%c", &ch)){sum += (ch - '0');}while (sum != 0){switch (sum % 10){case 0:strcpy(str[n], "ling"); break;case 1:strcpy(str[n], "yi"); break;case 2:strcpy(str[n], "er"); break;case 3:strcpy(str[n], "san"); break;case 4:strcpy(str[n], "si"); break;case 5:strcpy(str[n], "wu"); break;case 6:strcpy(str[n], "liu"); break;case 7:strcpy(str[n], "qi"); break;case 8:strcpy(str[n], "ba"); break;case 9:strcpy(str[n], "jiu"); break;default:break;}sum /= 10;n++;}for (int i = n - 1; i >= 0; i--){if (i != 0){printf("%s ", str[i]);}else{printf("%s", str[i]);}}return 0;}
0 0
- 07-0. 写出这个数 (20)
- 07-0. 写出这个数 (20)
- 07-0. 写出这个数 (20)
- 07-0. 写出这个数 (20)
- 07-0. 写出这个数 (20)
- 写出这个数 (20)
- 写出这个数(20)
- 写出这个数 (20)
- 写出这个数 (20)
- PAT 07-0. 写出这个数
- 7-0. 写出这个数 (20)
- 7-0. 写出这个数 (20)
- 7-0. 写出这个数 (20)
- PAT:7-0. 写出这个数 (20)
- 7-0. 写出这个数
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 如何创建和解压tar.xz文件
- Jump Game II
- netbeans for php项目常用快捷键说明
- 图像化矩阵Matlab程序
- 文件重命名之动态修改ListView里指定Item中的组件属性
- 07-0. 写出这个数 (20)
- cocos2dx 3.1.1 Lua相对于2.X的更新
- 行编辑程序实现
- Tomcat的启动方法
- centos6.5 防火墙关闭
- Java通过SSH2协议执行远程Shell脚本(ganymed-ssh2-build210.jar)
- ZOJ 2521 —— LED Display(二分匹配,最小路径覆盖)
- 周末
- 笔试题分析