解题思路:
(1)从给定数n的低位进行分离:int s=n%10;
(2)分离出的数,进行等效翻转操作:sum=sum*10+s; 为了防止溢出操作,将sum的类型定义为:long
(3)n/=10;继续循环操作
(4)检查是否溢出:如果sum>Integer.MAX_VALUE||sum<Integer.MIN_VALUE,则已经溢出,返回为0;如果没有溢出将sum强制类型转换为int即可...
分类:
其他好文 时间:
2015-06-19 10:28:32
阅读次数:
140
原文:类型 - PHP手册笔记类型简介 PHP 支持 8 种原始数据类型。 四种标量类型: boolean(布尔型,不区分大小写) integer(整型) float(浮点型,也称作double) string(字符串) 两种复合类型: array(数组) object(对象) 最后是两种特殊类型:...
分类:
Web程序 时间:
2015-06-19 10:08:28
阅读次数:
157
int atoi (const char * str); //Convert string to integer
char * itoa ( int value, char * str, int base ); //Convert integer to string (non-standard function)
#include
#include
int my_atoi(con...
分类:
其他好文 时间:
2015-06-19 01:34:25
阅读次数:
137
Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k....
分类:
其他好文 时间:
2015-06-19 00:07:36
阅读次数:
108
1227: Integer Game
Time Limit: 1 Sec Memory Limit:
128 MB
Submit: 9 Solved: 4
[Submit][Status][Web Board]
Description
Two players, S and T, are playing a game where they make alternate mov...
分类:
其他好文 时间:
2015-06-18 22:17:57
阅读次数:
192
D. Soldier and Number Game
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then
the second one tries to make m...
分类:
其他好文 时间:
2015-06-18 19:49:48
阅读次数:
111
Longest Increasing Continuous subsequence IIGive you an integer matrix (with row size n, column size m),find the longest increasing continuous subsequ...
分类:
其他好文 时间:
2015-06-18 19:21:53
阅读次数:
156
Description:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size t...
分类:
其他好文 时间:
2015-06-18 18:43:42
阅读次数:
89
题目
Determine whether an integer is a palindrome. Do this without extra space.
Some hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to...
分类:
其他好文 时间:
2015-06-18 17:22:44
阅读次数:
87
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then
the second one tries to make maximum possible number of rounds. ...
分类:
其他好文 时间:
2015-06-18 17:20:26
阅读次数:
116