程序讲解注释#include #includemain(){char dw[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰"};char dx[10][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};int je,a[17]={0},i,j,k;pri

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 18:35:10
程序讲解注释#include#includemain(){chardw[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰

程序讲解注释#include #includemain(){char dw[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰"};char dx[10][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};int je,a[17]={0},i,j,k;pri
程序讲解注释
#include
#include
main()
{char dw[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰"};
char dx[10][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
int je,a[17]={0},i,j,k;
printf("请输入一个小写整数金额:\n");
scanf("%d",&je);
i=0;
while(je!=0)
{k=je%10;
a[i]=k;
je=je/10;
i++;
}/*分离出小写金额中的各位数字*/
for(j=i-1;j>=0;j--)
{printf("%s",dx[a[j]]);
printf("%s",dw[j]);
}/*输出大写金额,并且紧跟单位*/
printf("\n");
}

程序讲解注释#include #includemain(){char dw[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰"};char dx[10][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};int je,a[17]={0},i,j,k;pri
#include <stdio.h>
#include <math.h>


int main()
{
//定义单位数组
char dw[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰"};
//定义数值转义数组
char dx[10][3]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
//变量
int je,a[17]={0},i,j,k;

printf("请输入一个小写整数金额:\n");
//获取输入值
scanf("%d",&je);
i=0;
//循环除10获取je的单位
while(je!=0)
{
//余数,根据循环分别代表个位,十位...
k=je%10;
//余数存储在数组中
a[i]=k;
//除10
je=je/10;
//i表示a数组的实际写入长度
i++;
}
/*分离出小写金额中的各位数字*/
for(j=i-1;j>=0;j--)
{
//打印转义字符
printf("%s",dx[a[j]]);
//打印单位
printf("%s",dw[j]);
}

printf("\n");
}