输入一个数n,将其反转输出。

要求输出时不含前导0

如输入365,输出563.

 输入520,输出25.

#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t;
	while(n>0)
	{
		if(n%10==0)           //舍去末尾0。 
		n/=10;
		else
		{
		t=n%10;
		n/=10;
		cout<<t;	
		}
	}
	cout<<endl;
	return 0;
 } 

猜你喜欢

转载自blog.csdn.net/qq_42387291/article/details/82735046
今日推荐