当前位置:网站首页>Reverse output an integer

Reverse output an integer

2022-06-26 01:49:00 So it is^^

thought : First %10 Find the last one and print it out , In addition 10 Remove the last digit , Yu Yu 10 Print this loop

#include<stdio.h>
int main()
{
	int n = 0;
	scanf("%d", &n);
	int a = 0, b = 0,i=0;
	while (n)                      //n The last digit is divided by 10 be equal to 0 For false , Exit loop 
	{
		i++;
		printf("%d", n % 10);      // Print out the last bit 
		n = n / 10;				   // After printing the last digit, i 10 Find the next , The last digit is divided by 10 be equal to 0
	}
	return 0;
}

原网站

版权声明
本文为[So it is^^]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260012409534.html