为下面的函数原型编写函数定义:
int ascii_to_integer(char *str);
这个字符串参数必须包含一个或者多个数字,函数应该把这些数字字符转换为整数并返回这个整数。如果字符串参数包含了任何非数字字符,函数就返回零。请不必担心算数溢出。
提示:这个技巧很简单:你每发现一个数字,把当前值乘以10,并把这个值和新的数字所代表的值相加。字符指针减去‘0’即将其对应的ASCII码...
分类:
其他好文 时间:
2015-04-04 10:42:49
阅读次数:
120
??
问题描述:
Implement
atoi to convert a string to an integer.
Hint: Carefullyconsider all possible input
cases. If you want a challenge, please do not seebelow and ask yourself what are the...
分类:
其他好文 时间:
2015-04-04 09:19:09
阅读次数:
162
??
问题描述:
Determine whether an integer is a palindrome. Do thiswithout extra space.
click to showspoilers.
Some hints:
Could negative integers be palindromes? (ie, -1)
If yo...
分类:
其他好文 时间:
2015-04-04 09:18:33
阅读次数:
137
HashMap是java里比较常用的一个集合类,我比较习惯用来缓存一些处理后的结果。最近在做一个Android项目,在代码中定义这样一个变量,实例化时,Eclipse却给出了一个 performance 警告。意思就是说用SparseArray来替代,以获取更好性能。老实说,对SparseArray...
分类:
其他好文 时间:
2015-04-04 09:03:55
阅读次数:
194
这一节,我们将学习Python的控制流语句,主要包括if、for、while、break、continue 和pass语句1. If语句if语句也许是我们最熟悉的语句。其使用方法如下:x=input("please input an integer:")if x0: print 'x>0'else:...
分类:
编程语言 时间:
2015-04-03 22:15:11
阅读次数:
142
Boring Counting
Time Limit: 3000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
In this problem you are given a number sequence P consisting of N integer and Pi is the ith element in t...
分类:
其他好文 时间:
2015-04-03 21:06:23
阅读次数:
179
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-04-03 19:11:16
阅读次数:
86
Delphi的参数可以分为:默认参数(传值)、var(传址)、out(输出)、const(常数)四类 可以对比C/C++的相关知识,类比学习。 1.默认参数是传值,不会被改变,例子function MyFun(x : Integer) : Integer;begin Inc(x); ...
??
问题描述:
Reverse digitsof an integer.
Example1: x =123, return 321
Example2: x =-123, return -321
问题分析:反转算法并不难,关键在于对溢出问题的考虑
代码:
public class Solution {
public int reverse(int x) {...
分类:
其他好文 时间:
2015-04-03 17:21:30
阅读次数:
84
Android基础-03
01_android下数据库的创建(重点)
在Android平台上,集成了一个嵌入式关系型数据库—SQLite,SQLite3支持 NULL、INTEGER、REAL(浮点数字)、TEXT(字符串文本)和BLOB(二进制对象)数据类型,虽然它支持的类型只有五种,但实际上sqlite3也接受varchar(n)、char(n)、decimal(p,s) 等数据类型,...
分类:
移动开发 时间:
2015-04-03 13:36:52
阅读次数:
167