#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long int LL;
map<LL, string> mp;
int DB(LL x) {
int k = 0;
while(x) {
++k;
x /= 10;
}
return k;
}
void f1(LL x) {
if(x)
cout << mp[x] ;
}
void f2(LL x) {
if(x / 10) {
cout << mp[x / 10] << "十" ;
f1(x % 10);
}
else
f1(x);
}
void f3(LL x) {
if(x / 100) {
cout << mp[x / 100] << "百" ;
if(DB(x % 100) < 2 && DB(x % 100))
cout << "零" ;
f2(x % 100);
}
else
f2(x);
}
void f4(LL x) {
if(x / 1000) {
cout << mp[x / 1000] << "千" ;
if(DB(x % 1000) < 3 && DB(x % 1000))
cout << "零" ;
f3(x % 1000);
}
else
f3(x);
}
void f5(LL x) {
if(x / 10000) {
cout << mp[x / 10000] << "万" ;
if(DB(x % 10000) < 4 && DB(x % 10000))
cout << "零" ;
f4(x % 10000);
}
else
f4(x);
}
void f6(LL x) {
if(x / 100000) {
f2(x / 10000); cout << "万" ;
if(DB(x % 10000) < 4 && DB(x % 10000))
cout << "零" ;
f4(x % 10000);
}
else
f5(x);
}
void f7(LL x) {
if(x / 1000000) {
f3(x / 10000); cout << "万" ;
if(DB(x % 10000) < 4 && DB(x % 10000))
cout << "零" ;
f4(x % 10000);
}
else
f6(x);
}
void f8(LL x) {
if(x / 10000000) {
f4(x / 10000); cout << "万" ;
if(DB(x % 10000) < 4 && DB(x % 10000))
cout << "零" ;
f4(x % 10000);
}
else
f7(x);
}
void f9(LL x) {
if(x / 100000000) {
cout << mp[x / 100000000] << "亿" ;
if(DB(x % 100000000) < 8 && DB(x % 100000000))
cout << "零" ;
f8(x % 100000000);
}
else
f8(x);
}
void f10(LL x) {
if(x / 1000000000) {
f2(x / 100000000); cout << "亿" ;
if(DB(x % 100000000) < 8 && DB(x % 100000000))
cout << "零" ;
f8(x % 100000000);
}
else
f9(x);
}
void (* F[13])(LL ) = {&f1, &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8, &f9, &f10};
int main() {
mp[0] = "零"; mp[1] = "一"; mp[2] = "二"; mp[3] = "三"; mp[4] = "四";
mp[5] = "五"; mp[6] = "六"; mp[7] = "七"; mp[8] = "八"; mp[9] = "九";
LL n;
cin >> n ;
if(n > 0) {
int db = DB(n);
F[db](n);
}
else if(n == 0) {
cout << mp[0] ;
}
else {
n = -n;
int db = DB(n);
cout << "负" ;
F[db](n);
}
cout << '\n' ;
return 0;
}
用C++写编译不给过啊,
#include <stdio.h>
typedef long long int LL;
char mp[20][3] = { 0xc1, 0xe3, 0, 0xd2, 0xbb, 0, 0xb6, 0xfe, 0, 0xc8, 0xfd, 0, 0xcb, 0xc4, 0, 0xce, 0xe5, 0, 0xc1, 0xf9, 0, 0xc6, 0xdf, 0, 0xb0, 0xcb, 0, 0xbe, 0xc5, 0, 0xca, 0xae, 0 };
char ch[4][3] = { 0xb0, 0xd9, 0, 0xc7, 0xa7, 0, 0xcd, 0xf2, 0, 0xd2, 0xda, 0 };
int DB(LL x) {
int k = 0;
while (x) {
++k;
x /= 10;
}
return k;
}
void f1(LL x) {
if (x)
printf("%s", mp[x]);
}
void f2(LL x) {
if (x / 10) {
printf("%s%s", mp[x / 10], mp[10]);
f1(x % 10);
}
else
f1(x);
}
void f3(LL x) {
if (x / 100) {
printf("%s%s", mp[x / 100], ch[0]);
if (DB(x % 100) < 2 && DB(x % 100))
printf("%s", mp[0]);
f2(x % 100);
}
else
f2(x);
}
void f4(LL x) {
if (x / 1000) {
printf("%s%s", mp[x / 1000], ch[1]);
if (DB(x % 1000) < 3 && DB(x % 1000))
printf("%s", mp[0]);
f3(x % 1000);
}
else
f3(x);
}
void f5(LL x) {
if (x / 10000) {
printf("%s%s", mp[x / 10000], ch[2]);
if (DB(x % 10000) < 4 && DB(x % 10000))
printf("%s", mp[0]);
f4(x % 10000);
}
else
f4(x);
}
void f6(LL x) {
if (x / 100000) {
f2(x / 10000); printf("%s", ch[2]);
if (DB(x % 10000) < 4 && DB(x % 10000))
printf("%s", mp[0]);
f4(x % 10000);
}
else
f5(x);
}
void f7(LL x) {
if (x / 1000000) {
f3(x / 10000); printf("%s", ch[2]);
if (DB(x % 10000) < 4 && DB(x % 10000))
printf("%s", mp[0]);
f4(x % 10000);
}
else
f6(x);
}
void f8(LL x) {
if (x / 10000000) {
f4(x / 10000); printf("%s", ch[2]);
if (DB(x % 10000) < 4 && DB(x % 10000))
printf("%s", mp[0]);
f4(x % 10000);
}
else
f7(x);
}
void f9(LL x) {
if (x / 100000000) {
printf("%s%s", mp[x / 100000000], ch[3]);
if (DB(x % 100000000) < 8 && DB(x % 100000000))
printf("%s", mp[0]);
f8(x % 100000000);
}
else
f8(x);
}
void f10(LL x) {
if (x / 1000000000) {
f2(x / 100000000); printf("%s", ch[3]);
if (DB(x % 100000000) < 8 && DB(x % 100000000))
printf("%s", mp[0]);
f8(x % 100000000);
}
else
f9(x);
}
void (*F[13])(LL) = { &f1, &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8, &f9, &f10 };
int main() {
LL n;
scanf("%lld", &n);
if (n > 0) {
int db = DB(n);
F[db](n);
}
else if (n == 0) {
printf("%s", mp[0]);
}
else {
n = -n;
int db = DB(n);
printf("\xb8\xba");
F[db](n);
}
putchar('\n');
return 0;
}