a008
自己co不出來
別人那抄來的
有BUG
但是AC了....
別人那抄來的
有BUG
但是AC了....
#include<iostream>
using namespace std;
char *unit[10]={"零","壹","貳","參","肆","伍","陸","柒","捌","玖",} ;
char *table[3]={"仟","佰","拾"};
char *thr[4]={"萬","億","兆","京"};
void dis(char *s,int len){
int i,c = (len+3)/4,pos;
i = (4-len%4)%4;
do{
for( ; i<4 ; i++){
pos = len-c*4+i;
if(s[ pos] ! = '0'){
printf("%s",unit[s[pos]-48]);
if(i! = 3)
printf("%s",table[i]);
}
else{
if( pos < len-1&&s[ pos+1]! = '0'&&i! = 3)
printf("%s",unit[0]);
}
}
if(c>1)
printf("%s",thr[c-2]);
i = 0;
}while(--c);
}//void
int main(){
char input[100];
while(cin>>input){
dis(input,strlen(input));
cout<< endl;
}
}
留言
張貼留言