??我的代码?
救命,这题真的写的都不如,我看都不想看一眼我的代码,ac率百分之40+,有没有人带带我.
#include<iostream>
using namespace std;
void number(int n){
switch(n){
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;
case 10:
cout << "shi" <<" ";
break;
}
}
int read(int n, int flag){
//输出万以内的数字
//依次检查各位
if(n / 1000){
number(n / 1000);
cout << "qian ";
}
n %= 1000;
if(!n)
return 0;
if(n / 100){
number(n / 100);
cout << "bai ";
}
if(flag && n / 100 == 0 && n % 100 / 10 != 0)
number(0);
n %= 100;
if(!n)
return 0;
if(n / 10 == 1)
cout << "shi ";
else if(n / 10){
number(n / 10);
cout << "shi ";
}
else number(0);
n %= 10;
if(!n)
return 0;
number(n);
return 0;
}
int main(){
int x, flag = 0;
cin >> x;
if(x / 100000000){
if(x / 100000000 <= 10)
number(x / 100000000);
else read(x / 100000000, flag);
cout << "yi" << " ";
flag = 1;
}
x %= 100000000;
if(x / 10000){
if(x / 10000 <= 10)
number(x / 10000);
else read(x / 10000, flag);
cout << "wan" << " ";
flag = 1;
}
x %= 10000;
read(x, flag);
return 0;
}
|