解答代码
#include#include #include #include #include #include using namespace std; string table[11]={"ling ","yi ","er ","san ","si ","wu ","liu ","qi ","ba ","jiu "}; string table2[4]={"qian ","bai ","shi "}; int flag=1; string change(string s) { int i,index=0; string result=""; char ss[4]=""; //过滤无效的前导0 for(i=0;i =0;i--) if(ss[i]=='0') record++; else break; if(record>0) flag=0; int k=4-length; //2位含十的有点特殊 if(length >data) { int pos=data.find('.'); if(pos!=string::npos) { s1=data.substr(0,pos); s2=data.substr(pos+1); } else { s1=data; } if(s1.length()>8) { string temp1=s1.substr(0,s1.length()-8); s1=s1.substr(s1.length()-8,s1.length()); string result1=change(temp1); if(result1.length()!=0) cout< 4) { string temp2=s1.substr(0,s1.length()-4); s1=s1.substr(s1.length()-4,s1.length()); string result2=change(temp2); if(result2.length()!=0) cout< 0) { string result3=change(s1); if(result3.length()!=0) cout<