Output a set of digits of no more than five digits and output each digit in positive and reverse order

1. Find out how many digits it is;
2. Output each digit separately;
3. Output each digit in reverse order, for example, if the original number is 321, output 123.

code show as below:

#include<stdio.h>
#include<stdlib.h>
void GetFigures(int a)
{
    
    
	
	int t[5];
	int i = 0;
	while(a!=0)
	{
    
    
		t[i]=a%10;             
		a/=10;                
		printf("%d",t[i]);       //倒序输出每一位
		i++;
	}
	printf("\n");
	for(int j=i-1;j>=0;j--)
	{
    
    
		printf("%d",t[j]);       //正序输出每一位
	}
	printf("\n%d\n",i);              //求位数
}
int main()
{
    
    
	
	GetFigures(12345);                 //样例12345输入
	return 0;
}

The results are as follows:

The results are as follows:
Hope to help you!

Guess you like

Origin blog.csdn.net/Gunanhuai/article/details/88785037