取各位数字c语言程序,取出数字的每一位

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include

main()

{

int x;

int a,b,c,d,e,t;

printf("请输入一个整数:");

scanf("%d",&x);

{ if (x/100000>=1)

printf("输入的数超过5位\n");

else if (x/10000>=1)

printf("要处理的数为5位数\n");

else if(x/1000>=1)

printf("要处理的数为4位数\n");

else if(x/100>=1)

printf("要处理的数为3位数\n");

else if(x/10>=1)

printf("要处理的数为2位数\n");

else if(x>=1)

printf("要处理的数为1位数\n");

else

printf("输入负数\n");

}

{

if (x/10000>=1)

a=x/10000;

x=x%10000;

printf("该数万位为%d\n",a);

if (x/1000>=1)

b=x/1000;

x=x%1000;

printf("该数千位为%d\n",b);

if (x/100>=1)

c=x/100;

x=x%100;

printf("该数百位为%d\n",c);

if (x/10>=1)

d=x/10;

x=x%10;

printf("该数十位为%d\n",d);

if (x>=1)

e=x;

printf("该数个位为%d\n",e);

printf("该数正序排列为%d%d%d%d%d\n",a,b,c,d,e);

printf("该数倒序排列为%d%d%d%d%d\n",e,d,c,b,a);

}

程序运行一直会出现内存的数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值