Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output "Fu" first if it is negative. For example, -123456789 is read as "Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu". Note: zero ("ling") must be handled correctly according to the Chinese tradition. For example, 100800 is "yi Shi Wan ling ba Bai".
Input Specification:
Each input file contains one test case, which gives an integer with no more than 9 digits.
Output Specification:
For each test case, PRint in a line the Chinese way of reading the number. The characters are separated by a space and there must be no extra space at the end of the line.
Sample Input 1:-123456789Sample Output 1:Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiuSample Input 2:100800Sample Output 2:yi Shi Wan ling ba Bai#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define Max 300using namespace std;struct user{ char name[11]; char pas[11];}a[Max],b[Max];char getc(char a[],int m){ return a[strlen(a)-1-m];}int main(){ int m,m1=0,m2=0,m3=0,k1,k2,k3,cc=0; int a[11],b[11],c[11]; char z[5][10]={"Qian","Bai","Shi"}; char s[11][11]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; for(int i=0;i<11;i++) { a[i]=b[i]=c[i]=0; } scanf("%d",&m); if(m<0){ printf("Fu "); m=-m; } m1=m/(100000000); m2=(m-m1*100000000)/10000; m3=m-m1*100000000-m2*10000; k1=m1;k2=m2;k3=m3; if(m==0) printf("ling"); else { if(m1!=0) { cc=1; int k=0,x=0; while (m1>0) { a[3-k]=m1%10; m1=m1/10; k++; } for(int i=0;i<4;i++) { if(a[i]!=0) { printf("%s",s[a[i]]); if(z[i]!=NULL&&i<=2) printf(" %s",z[i]); if(a[i+1]!=0||a[i+2]!=0||a[i+3]!=0) printf(" "); } } printf(" Yi"); } if(m2!=0) { if (k1!=0) printf(" "); int k=0,x=0; while (m2>0) { b[3-k]=m2%10; m2=m2/10; k++; } for(int i=0;i<4;i++) { if(i>=1) { if(x==0&&cc!=0){ printf("ling "); x=1; } } if(b[i]!=0) { cc=1; x=1; printf("%s",s[b[i]]); if(z[i]!=NULL&&i<=2) printf(" %s",z[i]); if(b[i+1]!=0||b[i+2]!=0||b[i+3]!=0) printf(" "); } } printf(" Wan"); } if(m3!=0) { if(k2!=0||(k2==0)&&k1!=0) printf(" "); int k=0,x=0; while (m3>0) { c[3-k]=m3%10; m3=m3/10; k++; } for(int i=0;i<4;i++) { if(i>=1) { if(x==0&&cc!=0){ printf("ling "); x=1; } } if(c[i]!=0) { x=1; printf("%s",s[c[i]]); if(z[i]!=NULL&&i<=2) printf(" %s",z[i]); if(c[i+1]!=0||c[i+2]!=0||c[i+3]!=0) printf(" "); } } } } system("pause"); return 0;}
新闻热点
疑难解答