码迷,mamicode.com
首页 >  
搜索关键字:return    ( 60766个结果
一个字符串中查找另一个字符串出现的次数
#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
计算一个字符串的长度,mystrlen
#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
Leetcode 221 Maximal Square
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
Leetcode 121 Best Time to Buy and Sell Stock
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
Leetcode Best Time to Buy and Sell Stock II
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
LeetCode--Reverse Integer
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
C++中枚举定义运算符
由于枚举也是用户定义类型,所以是可以定义运算符, 如: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
C++atoi与atof
#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
[Leetcode]-Pascal's Triangle II
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
Pascal's Triangle
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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!