×
解除綁定,重新設定系統帳號的密碼
您的系統帳號 ID:
您的系統帳號:
您的帳號暱稱:
設定新密碼:
設定新密碼:
×
請輸入要加入的「課程代碼」
請向開設課程的使用者索取「課程代碼」
分類題庫
解題動態
排行榜
討論區
競賽區
登入
註冊
發表新討論
#3847: WC問題
pellok
(哈比熊)
學校:
朝陽科技大學
編號:
12172
×
傳送站內訊息
傳給:
主題:
內容:
來源:
[210.240.215.252]
註冊時間:
2010-06-09 09:24:33
最後登入時間:
2010-06-23 15:17:52
a008.
中文大寫數字
--
admin
| From: [210.240.215.252] | 發表日期: 2010-06-10 15:54
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
string str="零壹貳參肆伍陸柒捌玖拾佰仟萬億";
string menber_change_word(int);
int main(){
long a;
while(cin>>a && a>=0 && a<=2147483647){
if(a<10000){
cout<<menber_change_word(a%10000)<<endl;
}else if(a<100000000){
cout<<menber_change_word(a/10000)<<"萬";
if(a%10000 <1000 && a%10000 !=0) cout<<"零";
cout<<menber_change_word(a%10000)<<endl;
}else{
cout<<menber_change_word(a/100000000)<<"億";
if(a%100000000 <100000000 && a%100000000 !=0) cout<<"零";
a%=100000000;
if(a!=0) cout<<menber_change_word(a/10000)<<"萬";
if(a%10000 <1000 && a%10000 !=0) cout<<"零";
cout<<menber_change_word(a%10000)<<endl;
}
}
return 0;
}
string menber_change_word(int x){
string word="";
if(x<=9){
if(x==0) return word;
word+=str[x%10*2];
word+=str[x%10*2+1];
}else if(x<=99 && x>=10){
word+=str[x/10*2];
word+=str[x/10*2+1];
word+=str[20];
word+=str[21];
if(x%10==0) return word;
word+=str[x%10*2];
word+=str[x%10*2+1];
}else if(x<=999 && x>=100){
word+=str[x/100*2];
word+=str[x/100*2+1];
x%=100;
word+=str[22];
word+=str[23];
if(x==0) return word;
if(x<=9){
word+=str[0];
word+=str[1];
}else{
word+=str[x/10*2];
word+=str[x/10*2+1];
word+=str[20];
word+=str[21];
}
if(x%10==0) return word;
word+=str[x%10*2];
word+=str[x%10*2+1];
}else{
word+=str[x/1000*2];
word+=str[x/1000*2+1];
x%=1000;
word+=str[24];
word+=str[25];
if(x==0) return word;
if(x<=99){
if(x>=10){
word+=str[0];
word+=str[1];
}
}else{
word+=str[x/100*2];
word+=str[x/100*2+1];
x%=100;
word+=str[22];
word+=str[23];
}
if(x==0) return word;
if(x<=9){
word+=str[0];
word+=str[1];
}else{
word+=str[x/10*2];
word+=str[x/10*2+1];
word+=str[20];
word+=str[21];
}
if(x%10==0) return word;
word+=str[x%10*2];
word+=str[x%10*2+1];
}
return word;
}
與正確輸出不相符(line:1)
您的答案為: ��萬���貟���揃
正確答案為: 壹萬貳仟參佰肆拾伍