- 博客(12)
- 资源 (2)
- 收藏
- 关注
原创 PAT 1010
#include using namespace std;long long int toD(string str,long long int radix){ long long int num=0; for(int i=0;i<str.length();i++){ if(str[i]>='a'&&str[i]<='z'){ num=nu
2014-08-30 21:03:18 535
转载 虚函数 与 纯虚函数 区别
首先:强调一个概念定义一个函数为虚函数,不代表函数为不被实现的函数。定义他为虚函数是为了允许用基类的指针来调用子类的这个函数。定义一个函数为纯虚函数,才代表函数没有被实现。定义纯虚函数是为了实现一个接口,起到一个规范的作用,规范继承这个类的程序员必须实现这个函数。1、简介假设我们有下面的类层次:[cpp] view plaincopy
2014-08-23 16:20:25 533
原创 多态 和 重载的区别
多态是基于对抽象方法的覆盖来实现的,用统一的对外接口来完成不同的功能。重载也是用统一的对外接口来完成不同的功能。那么两者有什么区别呢?重载,是指允许存在多个同名方法,而这些方法的参数不同。重载的实现是:编译器根据方法不同的参数表,对同名方法的名称做修饰。对于编译器而言,这些同名方法就成了不同的方法。它们的调用地址在编译期就绑定了。多态:是指子类重新定义父类的虚方法(virtua
2014-08-20 09:57:04 948
转载 C/S B/S区别
C/S结构,即Client/Server(客户机/服务器)结构,是大家熟知的软件系统体系结构,通过将任务合理分配到Client端和Server端,降低了系统的通讯开销,可以充分利用两端硬件环境的优势。早期的软件系统多以此作为首选设计标准。。 B/S结构,即Browser/Server(浏览器/服务器)结构,是随着Internet技术的兴起,对C/S结构的一种变化或者改进的结构。在这种结
2014-08-19 08:59:43 1037
转载 C++拷贝构造函数详解
一. 什么是拷贝构造函数首先对于普通类型的对象来说,它们之间的复制是很简单的,例如:[c-sharp] view plaincopyint a = 100; int b = a; 而类对象与普通对象不同,类对象内部结构一般较为复杂,存在各种成员变量。下面看一个类对象拷贝的简单例子。
2014-08-17 14:08:22 529
原创 leetcode Palindrome Partitioning(*)
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","
2014-08-14 20:13:53 520
原创 leetcode Populating Next Right Pointers in Each Node(*)
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.
2014-08-13 20:49:28 482
原创 leetcode Linked List Cycle(I II)(*)
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?
2014-08-12 20:26:10 416
原创 leetcode Reorder List(*)
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it t
2014-08-12 20:15:59 462
原创 leetcode LRU Cache(**)
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if
2014-08-06 20:49:34 595
原创 leetcode Best Time to Buy and Sell Stock(I~III)(*)
I:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the
2014-08-05 20:51:35 595
转载 编程之美4.7蚂蚁爬杆扩展问题附猎人抓狐狸(必胜策略)
4.7节讲的是一根长27cm的木棍上,在5个点上有5只蚂蚁,蚂蚁在开始的时候朝任意方向出发,只能掉头或者往前走。让任意两只蚂蚁碰头时,它们同时掉头朝反方向走。假设蚂蚁的速度都是一秒一厘米,求蚂蚁都离开木棍的最短时间和最长时间。 穷举很麻烦,书上的思路非常精巧,即把蚂蚁碰头后掉头走,看做两个蚂蚁相遇后擦肩而过。这样就可以把蚂蚁的运动看做是独立的,是否碰头并不重要。代码也很简单,不过书上
2014-08-05 11:29:17 2270
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人