上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页
摘要: 题目:请实现一个函数,把字符串中的每个空格都替换成"%20"。例如输入"We are happy."则输出"We%20are%20happy."这道题一看到就能想到直接从前到后遍历字符串,当遇到空格时候先将空格后面的字符串中每个字符向后移动两个位置,然后再把空格及空格之后的两个字符替换为"%20"剑... 阅读全文
posted @ 2015-07-21 10:56 vpoet 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断该数组中是否有该整数。算法流程如下:比如一个二维数组array:1 1 2 8 92 3 2 4 9 124 5 4 7 10 136 7 6 8 1... 阅读全文
posted @ 2015-07-20 22:35 vpoet 阅读(222) 评论(0) 推荐(0) 编辑
摘要: #ifndef,#define,#end 是宏定义的一种---条件编译这样我直接举个例子好了:我定义两个相同的类A分别在single.h和singlenew.hsingle.h: 1 #include 2 using namespace std; 3 4 class A 5 { 6 public... 阅读全文
posted @ 2015-07-20 21:47 vpoet 阅读(958) 评论(0) 推荐(0) 编辑
摘要: 题目:设计一个类,我们只能生成该类的一个实例这道题显然是对设计模式的考察,很明显是单例模式。什么是单例模式呢,就是就像题目所说的只能生成一个类的实例。那么我们不难考虑到下面几点:1.不能new多个对象,那么必然该类的构造函数是私有的2.类对象只有一个,那么必然该对象只能有一个私有的静态成员变量,该成... 阅读全文
posted @ 2015-07-20 21:16 vpoet 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 题目:如下为类型CMyString的声明,请为该类型添加赋值运算符函数 1 class CMyString 2 { 3 public: 4 CMyString(char *pData=NULL); 5 CMyString(const CMyString & str); 6 ~... 阅读全文
posted @ 2015-07-20 20:37 vpoet 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2015-07-20 09:33 vpoet 阅读(170) 评论(0) 推荐(1) 编辑
摘要: Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].Note:Try to come... 阅读全文
posted @ 2015-07-20 09:32 vpoet 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Implementint sqrt(int x).Compute and return the square root ofx. 1 int mySqrt(int x) 2 { 3 if(x==1) 4 return 1; 5 6 /* for(int i=2;i<... 阅读全文
posted @ 2015-07-20 09:31 vpoet 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --... 阅读全文
posted @ 2015-07-20 09:30 vpoet 阅读(199) 评论(0) 推荐(1) 编辑
摘要: Implement pow(x,n).1 double myPow(double x, int n) 2 {3 if(n==0) 4 return 1.0; 5 if(n<0) 6 return 1.0/pow(x,-n); 7 ret... 阅读全文
posted @ 2015-07-20 09:29 vpoet 阅读(119) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * struct ListNo... 阅读全文
posted @ 2015-07-20 09:29 vpoet 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is great... 阅读全文
posted @ 2015-07-20 09:28 vpoet 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two. 1 bool isPowerOfTwo(int n) 2 { 3 if(n1)10 {11 if(n%2==0)12 ... 阅读全文
posted @ 2015-07-20 09:27 vpoet 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
posted @ 2015-07-20 09:23 vpoet 阅读(220) 评论(0) 推荐(0) 编辑
摘要: Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri... 阅读全文
posted @ 2015-07-20 09:22 vpoet 阅读(272) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页