#include
#include
int strstrcount( char *str1, char *str2 )
{
char *str = str1;
int c = 0;
while( (str = strstr( str, str2 )) != NULL )
{
c++;
str++;
}
return c;
}
int main()
{...
分类:
其他好文 时间:
2015-07-04 21:04:33
阅读次数:
131
#include
int mystrlen(char *p)
{
int size = 0;
if(!p)//如果是空指针
return -1;
while(*p)
{
p++;
size++;
}
return size;
}
int main()
{
char *s;
char c[20];
s=c;
g...
分类:
其他好文 时间:
2015-07-04 19:49:43
阅读次数:
174
class Solution:
# @param {character[][]} matrix
# @return {integer}
def maximalSquare(self, matrix):
if matrix == []: return 0
m, n = len(matrix), len(matrix[0])
...
分类:
其他好文 时间:
2015-07-04 18:29:27
阅读次数:
191
class Solution:
# @param {integer[]} prices
# @return {integer}
def maxProfit(self, prices):
if len(prices) <= 1: return 0
low = prices[0]; mostProfit = 0
for i ...
分类:
其他好文 时间:
2015-07-04 18:29:06
阅读次数:
131
class Solution:
# @param {integer[]} prices
# @return {integer}
def maxProfit(self, prices):
profit = 0;
for i in xrange(1, len(prices)):
if prices[i] > prices[...
分类:
其他好文 时间:
2015-07-04 18:28:27
阅读次数:
132
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321问题描述: 将整数个十百位反序输出。注意特殊情况:1)溢出情况:To check for overflow/underflow...
分类:
其他好文 时间:
2015-07-04 18:24:44
阅读次数:
120
由于枚举也是用户定义类型,所以是可以定义运算符, 如:1 enum Day {sun, mon, tue, wen, thu, fri, sat};2 3 Day& operator++(Day& d)4 {5 return d = (sat == d) ? sun : Day(sta ...
分类:
编程语言 时间:
2015-07-04 18:11:03
阅读次数:
111
#include
using namespace std;
static int sflags = 0;
//atof的函数实现。
bool Isnum(char ch)
{
return (ch - '0') >= 0 || (ch - '0') <= 9;
}
float Getnum(char *s,int flags)
{
float count = 0...
分类:
编程语言 时间:
2015-07-04 16:49:22
阅读次数:
123
Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3,
Return [1,3,3,1].Note:
Could you optimize your algorithm to use only O(k) extra space?Hide Tags : Array
题目:返回帕...
分类:
其他好文 时间:
2015-07-04 15:36:11
阅读次数:
119
return tmpLarge.push_back(tmp);不等价于tmpLarge.push_back(tmp);
return tmpLarge;因为push_back()返回值类型为void,而后者返回tmpLarge的类型。代码如下:class Solution {
public:
vector<vector> generate(int numRows) {...
分类:
其他好文 时间:
2015-07-04 15:35:21
阅读次数:
116