Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
反转整形
主要是注意边界条件
1: 如果整数的最后一位为0,应该输出什么?例如,如100。
2: 逆转整数可能溢出;假设输入是一个32位整数,然后反向1000000003溢出

//
// PalindromeNumber.c
// Algorithms
//
// Created by TTc on 15/6/6.
// Copyright (c) 2015年 TTc. All rights reserved.
//
#include "PalindromeNumber.h"
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
static
int reverse(int x) {
long long val = 0;
do
{
val = val * 10 + x % 10;
x /= 10;
} while (x);
return (val > INT_MAX || val < INT_MIN) ? 0 : val;
}
/*