展开全部
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void ChangeChn(int n){
char Chinese[][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖","拾"};
char Unit[][3]={"万","千","百","十","圆","角","分"},nArray[11];
int ln,i,j,m=1;
ln=strlen(itoa(n,nArray,10));
for(i=0;i<ln;i++){
if(i<ln-1&&nArray[i]=='0'&&nArray[i-1]=='0') continue;
if(nArray[i]=='0'){
m=0;
for(j=i+1;j<ln;j++){
if(nArray[j]!='0') m++;
}
}
if(m==0){
printf("%s",Unit[4]);
break;
}
if(nArray[i]=='0'&&(i!=ln-1)){
printf("%s",Chinese[nArray[i]&15]);
}
if(nArray[i]=='0'&&(i==ln-1)){
printf("%s",Unit[5-ln+i]);
}
if(nArray[i]!='0'){
printf("%s%s",Chinese[nArray[i]&15],Unit[5-ln+i]);
}
}
}
void main(){
int nDec;
printf("请输入一个十进制数...\nnDec=");
scanf("%d",&nDec);
printf("对应的中文大写是:\n");
ChangeChn(nDec);
printf("\n");
}
根据前面那位改的,解决下出现0时的情况。能力有限,判断方法很笨拙,用来参考参考吧。
#include "stdlib.h"
#include "string.h"
void ChangeChn(int n){
char Chinese[][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖","拾"};
char Unit[][3]={"万","千","百","十","圆","角","分"},nArray[11];
int ln,i,j,m=1;
ln=strlen(itoa(n,nArray,10));
for(i=0;i<ln;i++){
if(i<ln-1&&nArray[i]=='0'&&nArray[i-1]=='0') continue;
if(nArray[i]=='0'){
m=0;
for(j=i+1;j<ln;j++){
if(nArray[j]!='0') m++;
}
}
if(m==0){
printf("%s",Unit[4]);
break;
}
if(nArray[i]=='0'&&(i!=ln-1)){
printf("%s",Chinese[nArray[i]&15]);
}
if(nArray[i]=='0'&&(i==ln-1)){
printf("%s",Unit[5-ln+i]);
}
if(nArray[i]!='0'){
printf("%s%s",Chinese[nArray[i]&15],Unit[5-ln+i]);
}
}
}
void main(){
int nDec;
printf("请输入一个十进制数...\nnDec=");
scanf("%d",&nDec);
printf("对应的中文大写是:\n");
ChangeChn(nDec);
printf("\n");
}
根据前面那位改的,解决下出现0时的情况。能力有限,判断方法很笨拙,用来参考参考吧。
展开全部
供你参考……
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void ChangeChn(int n){
char Chinese[][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖","拾"};
char Unit[][3]={"万","千","百","十","圆","角","分"},nArray[11],ln,i;
ln=strlen(itoa(n,nArray,10));
for(i=0;i<ln;i++)
printf("%s%s",Chinese[nArray[i]&15],Unit[5-ln+i]);
}
void main(void){
int nDec;
printf("请输入一个十进制数...\nnDec=");
scanf("%d",&nDec);
printf("对应的中文大写是:\n");
ChangeChn(nDec);
printf("\n");
}
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void ChangeChn(int n){
char Chinese[][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖","拾"};
char Unit[][3]={"万","千","百","十","圆","角","分"},nArray[11],ln,i;
ln=strlen(itoa(n,nArray,10));
for(i=0;i<ln;i++)
printf("%s%s",Chinese[nArray[i]&15],Unit[5-ln+i]);
}
void main(void){
int nDec;
printf("请输入一个十进制数...\nnDec=");
scanf("%d",&nDec);
printf("对应的中文大写是:\n");
ChangeChn(nDec);
printf("\n");
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询