1002. 写出这个数 (20)
来源:互联网 发布:淘宝网店从哪里注册 编辑:程序博客网 时间:2024/06/07 00:49
读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。
输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10100。
输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1空格,但一行中最后一个拼音数字后没有空格。
输入样例:1234567890987654321123456789输出样例:
yi san wu
#include <iostream>using namespace std;void shuchu(int x){switch(x){case 0:cout<<"ling";break; case 1:cout<<"yi";break;case 2:cout<<"er";break;case 3:cout<<"san";break;case 4:cout<<"si";break;case 5:cout<<"wu";break;case 6:cout<<"liu";break;case 7:cout<<"qi";break;case 8:cout<<"ba";break;case 9:cout<<"jiu";break;}}void zhengxu(int x){if (x==0) return;zhengxu(x/10);if (x/10!=0){cout<<" ";}shuchu(x%10);}int main(){char str[100];cin>>str;int i=0;int sum=0;while (str[i]!='\0'){ sum+=str[i]-'0'; i++;}if (sum==0){shuchu(sum);}else{zhengxu(sum);}return 0;}
阅读全文
0 0
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 1002. 写出这个数 (20)
- 指令与控制器之间的交互
- angularjs学习笔记(二)控制器1
- javascription基础知识【学习整理中】
- Android设计模式
- malloc\colloc
- 1002. 写出这个数 (20)
- Shell echo命令
- shadowsocks后端一键脚本
- python__爬虫自学异常 (二)
- 读取MP3内嵌信息
- 10065---【Java多线程】线程池的工作原理详解(上)
- K-近邻算法
- POJ 2422 The Wolves and the Sheep 笔记
- IntelliJ IDEA安装、配置、测试(win7_64bit)