继承和组合的使用原则:
1、很多资料中提到的一点,如果两个类之间是is-a的关系,那么就使用继承,而如果是has-a的关系就使用组合。
但是这也不是代表is-a是使用继承的绝对理由,有时候为了消除继承关系带来的耦合,使用组合可以更好的实现封装细节。
如果在一个系统中大量应用继承,继承层次深了,那么会给系统的开发和维护带来困难。
2、无论何时,如果...
分类:
其他好文 时间:
2014-05-15 01:38:59
阅读次数:
240
Substrings
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1571 Accepted Submission(s): 459
Problem Description
XXX has an arra...
分类:
其他好文 时间:
2014-05-15 01:35:46
阅读次数:
338
Series Determination
题目描述
Boudreaux and Thibodeaux aren't very good at math, so they need you to write a program that can de...
分类:
其他好文 时间:
2014-05-15 01:28:56
阅读次数:
313
Linked List Cycle
Total Accepted: 17148 Total
Submissions: 49300My Submissions
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra sp...
分类:
其他好文 时间:
2014-05-15 00:13:50
阅读次数:
279
Linked List CycleGiven a linked list, determine
if it has a cycle in it.Follow up:Can you solve it without using extra
space?做完Linked List Cycle II在做这...
分类:
其他好文 时间:
2014-05-14 23:30:00
阅读次数:
399
插入排序是最基本基于比较的排序方法,其时间复杂度为Ο(n2),最好情况为初始有序,最坏为逆序。
伪代码如下: insertionSort(A,n) for i=1 to n do key=A[i] for j=i-1 to 0 if ar...
分类:
其他好文 时间:
2014-05-14 22:35:28
阅读次数:
326
Pat1043代码题目描述:A Binary Search Tree (BST) is
recursively defined as a binary tree which has the following properties:The left
subtree of a node contain...
分类:
其他好文 时间:
2014-05-14 22:03:25
阅读次数:
487
【题目】
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.
Notes: It is intended for this problem to be s...
分类:
其他好文 时间:
2014-05-14 21:00:57
阅读次数:
304
【题目】
Determine whether an integer is a palindrome. Do this without extra space.
【题意】
题意判断一个整数是否是回文数
注意一下几点:
1. 不能用额外的空间
2. 负数不是回文数...
分类:
其他好文 时间:
2014-05-14 20:31:10
阅读次数:
298
出现no write has been done on this connection解决方案...
分类:
数据库 时间:
2014-05-14 19:42:51
阅读次数:
403