解题思路: 这题用这个残缺不全的代码能AC我都不敢相信自己的眼睛QWQ
注意事项:
参考代码:
#include <stdio.h> char s[12][5] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu","shi"}; long long temp; void f(long long n,long long m,int k){ if(n == 0){ if(k == 11) //十亿位 printf("shi "); return; } else{ f(n/10,m*10,k+1); if(k == 9){ //亿位 if(n%10 != 0) printf("%s yi ", s[n%10]); } if(k == 8){ //千万位 if(n%10 != 0) printf("%s qian ", s[n%10]); } if(k == 7){ //百万位 if(n%10 != 0) printf("%s bai ", s[n%10]); } if(k == 6){ //十万位 if(n%10 == 1) printf("shi "); else if(n%10 != 0) printf("%s shi ", s[n%10]); else if(n%10 == 0) printf("ling "); } if(k == 5){ //万位 if(n%10 != 0) printf("%s wan ", s[n%10]); else if(temp%10 != 0 && temp/10%10 != 0 && temp/100%10 == 0 && temp/1000%10 == 0 && temp/10000%10 == 0) printf("wan ling "); else if(n%10 == 0) printf("wan "); } if(k == 4){ //千位 if(n%10 != 0) printf("%s qian ", s[n%10]); else if(temp%10 != 0 && temp/10%10 != 0 && temp/100%10 == 0 && temp/1000%10 == 0 && temp/10000%10 != 0) printf("ling "); else if(temp%10 == 0 && temp/10%10 == 0 && temp/100%10 != 0 && temp/1000%10 == 0 && temp/10000%10 != 0) printf("ling "); } if(k == 3){ //百位 if(n%10 != 0) printf("%s bai ", s[n%10]); else if(temp%10 != 0 && temp/10%10 != 0 && temp/100%10 == 0 && temp/1000%10 != 0) printf("ling "); else if(temp%10 == 0 && temp/10%10 != 0 && temp/100%10 == 0 && temp/1000%10 != 0) printf("ling "); } if(k == 2){ //十位 if(temp%10 == 0 && temp/10%10 != 0 && temp/100%10 == 0 && temp/1000%10 != 0) printf("%s shi", s[n%10]); else if(temp%10 == 0 && temp/10%10 != 0 && temp/100%10 != 0) printf("%s shi ", s[n%10]); else if(temp%10 != 0 && temp/10%10 != 0 && temp/100%10 != 0) printf("%s shi ", s[n%10]); else if(temp%10 == 0 && temp/10%10 == 1) printf("shi "); else if(temp%10 == 0 && temp/10%10 >= 2) printf("%s shi ", s[n%10]); else if(temp%10 != 0 && temp/10%10 == 1) printf("shi "); else if(temp%10 != 0 && temp/10%10 >= 2) printf("%s shi ", s[n%10]); else if(temp%10 != 0 && temp/10%10 == 0) printf("ling "); } if(k == 1){ //个位 if(n%10 != 0) printf("%s ", s[n%10]); } } } int main(){ long long n; scanf("%lld", &n); temp = n; f(n,1,1); return 0; }
0.0分
14 人评分
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:701 |
钟神赛车 (C++代码)浏览:905 |
C语言训练-字符串正反连接 (C语言代码)浏览:664 |
C语言训练-自由落体问题 (C语言代码)浏览:1775 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:827 |
文科生的悲哀 (C语言代码)浏览:1538 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:569 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:609 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:594 |
C语言训练-排序问题<1> (C语言代码)浏览:369 |