整数反转

题目
公司:迅雷
类型:数学规律
题意:把一个32位的有符号整数反转。注意虽然输入保证是32位的,但是反转过后就可能溢出,所以直接用longlong存。这道题是leetcode上的原题。

#include 
using namespace std;
const int N = 1e5+5;
int a[N];
int main(){
	long long n, res = 0;
	scanf("%lld", &n);
	while(n){
		res = res*10 + n%10;
		n /= 10;
	}
	printf("%lld\n", res);
	return 0;
} 

你可能感兴趣的:(2018年校招真题,数论基础)