#include
using namespace std;
#include
int main( void )
{
string number[15] = { "零", "壹", "貳", "參", "肆", "伍", "陸", "柒", "捌", "玖" };
string value[15] = { "", "拾", "佰", "仟", "萬", "拾", "佰", "仟", "億", "拾", "佰"};
int num;
while( cin >> num )
{
int num_divide[15] = {0};
int value_no = 0;
int max_value = 0;
for(value_no=0;num>0;value_no++)
{
num_divide[value_no] = num % 10;
num /= 10;
}
max_value = value_no-1;
for( int i = max_value ; i >= 0 ; i-- )
{
if( num_divide[i] != 0 )
cout << number[num_divide[i]] << value[i];
else if( i == 4 || i == 8 )
cout << value[i];
else if( i==0 )
cout<<"";
else if( num_divide[i-1] != 0 )
cout << number[num_divide[i]];
}
cout << endl;
}
return 0;
}
Tuesday, July 26, 2011
a008: 中文大寫數字
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment