Enter a five-digit number, respectively, to achieve positive sequence, reverse output of each of his number (write your own)

main body:

int a = 0,b = 0;
	printf("请输入a的值(a为五位数):");
	scanf_s("%d", &a);

Positive sequence:

int f = a;
	for (int i = 0; i <5; i++)//逆序
	{

		b= f%10;
		f = f / 10;
		printf("%d ",b);
	}

Reverse:

int c = 10000, d;
	int g = a;
	for (int i = 0; i < 5; i++)//正序
	{		
		d= g / c;
		g = g -d*c;
		c = c / 10;
		printf("%d ", d);
	}

Note: This code is pure C language, vs2019;

 

Welcome to ask questions!

 

Published 15 original articles · won praise 0 · Views 230

Guess you like

Origin blog.csdn.net/qq_44423388/article/details/103552410