1.5 编程基础之循环控制 29 数字反转

题目的链接

http://noi.openjudge.cn/ch0105/29/

#include <iostream>
using namespace std;
int main()
{
	int x,a,b,c;
	
	int ans=0;
	
	cin>>x;
	
	if( x<0)
	{
		cout<<"-";
		x=-x;
	}
	
	while( x )
	{
		ans=ans*10+x%10;
	    x=x/10;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

 


 

 

猜你喜欢

转载自blog.csdn.net/dllglvzhenfeng/article/details/121846192
1.5