/* 输入一个五位以内的正整数,(1)判断它是一个几位数;(2)请按序输出其各位数字;(3)逆序输出其各位数字。
如输入:56439,输出:5位数
5,6,4,3,9
9,3,4,6,5
*/
1#include<stdio.h>
2
3 int a[5],b[5];
4 void display(int i)
5 {printf("the positive sort is:");
6 int j=0;
7 for(j=i;j>0;j--)
8 printf("%d",a[j-1]);
9 printf("\n");
10 printf("the negative sort is:");
11 for(j=0;j<i;j++)
12 printf("%d",a[j]);
13 printf("\n");
14
15 }
16
17 void main()
18 {
19 int num;
20 printf("input your number:");
21 scanf("%d",&num);
22 if(num<0||num>99999) {printf("error!\n");}
23 e
输入一个五位以内的正整数,(1)判断它是一个几位数;(2)请按序输出其各位数字;(3)逆序输出其各位数字。
最新推荐文章于 2024-06-26 09:24:48 发布
该程序接收一个五位以内的正整数,判断其位数,并按序和逆序输出其各位数字。如果输入的数字超出范围,程序会提示错误。
摘要由CSDN通过智能技术生成