输入int123,输出string一百二十三,假设最大是亿。

来源:互联网 发布:国外网址域名 编辑:程序博客网 时间:2024/06/05 18:23
#include <stdio.h>#include <math.h>void main(){char *a[7]={"0","0","十","百","千","万","亿"};char *b[10]={"0","一","二","三","四","五","六","七","八","九"};int i,n,num=0,temp;scanf("%d",&n);temp = n;while(temp!=0){temp=temp/10;num++;}temp = n;while(temp!=0){i=temp/(pow(10,(num-1)));printf("%s",b[i]);if(num>1){printf("%s",a[num]);}temp=temp-i*(pow(10,(num-1)));num--;}printf("\n");}

0 0
原创粉丝点击