├── 360 ├── 2014-360校园招聘技术类面试题.md └── 2014-360校园招聘技术类笔试题.md ├── alipay.png ├── Microsoft ├── InterviewQuestions.md └── src │ ├── BeautifulString.java │ ├── CombinationLock.java │ ├── PerformanceLog.java │ └── StringMatchingContentLength.java ├── converter.sh ├── Meituan └── 2015美团校招部分笔试题.md ├── Tecent └── 2014腾讯实习一面面试题.md ├── Baidu ├── 百度2015校园招聘面试题回忆录(成功拿到offer).md └── 百度2014研发类校园招聘笔试题解答.md ├── README.md ├── Alibaba └── 阿里2015校招面试回忆录(成功拿到offer).md ├── Skills └── 10道C++输出易错笔试题收集(敢进来挑战吗?).md └── LICENSE /alipay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanxuezaipiao/IT-Interviews-Sharing/HEAD/alipay.png -------------------------------------------------------------------------------- /Microsoft/InterviewQuestions.md: -------------------------------------------------------------------------------- 1 | 在线:[微软2015校园招聘 技术类职位在线笔试](http://hihocoder.com/contest/mstest2015oct/problems) -------------------------------------------------------------------------------- /converter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # vim file.txt -c "e ++enc=GB18030" 3 | # :set fileencoding=utf-8 4 | for i in `find . -name '*.md'` 5 | do 6 | if test -f $i 7 | then 8 | touch temp.md 9 | iconv -f gb18030 -t utf8 $i > temp.md 10 | cp temp.md $i 11 | rm temp.md 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /Meituan/2015美团校招部分笔试题.md: -------------------------------------------------------------------------------- 1 | 美团笔试全部都是算法题,一共8题,前面4道想对偏简单,后面4道偏难,前面4题就不贴出来了,大部分都会,下面给出后面四题的题目。 2 | 3 | 1. 求斜率最大值:平面上N个点,每两个点都确定一条直线,求出斜率最大的那条直线所通过的两个点(斜率不存在的情况不考虑)。时间效率越高越好。已知了一个排序算法。 4 | 5 | 提示:假设有(Ax,Ay)、(Bx, By)两点(不相邻)画出的直线斜率为K,则点(Cx, Cy)(在AB之间Cx > Ax, Cx < Bx) 6 | 则ABC三点组成三角形(若组成不了三角形说明在一条直线上)则直线AC或者BC至少有一点的斜率绝对值大于AB的斜率绝对值。 7 | 8 | 2. 最接近0的子序列,比如[1, 5, -3, 2, -1, 4],则为[-3, 2]或[2, -1]。 9 | 10 | 3. 排列组合问题:汉子所有可能的拼音组合。 11 | 12 | 4. 类似最短摘要问题:从一个长字符串中查找包含给定字符集合的最短子串。例如,长串为“aaaaaaaaaacbebbbbbdddddddcccccc”,字符集为 {abcd},那么最短子串是“acbebbbbbd”。 13 | -------------------------------------------------------------------------------- /Tecent/2014腾讯实习一面面试题.md: -------------------------------------------------------------------------------- 1 | 下面是我和同学去面试腾讯实习一面的面试题,仅供参考! 2 | 3 | ## 我的面试题## 4 | 时间:2014.4.23 下午2:40 ~ 3:15 5 | ####网络:#### 6 | - TCP/IP协议栈各个层次及分别的功能 7 | 下面提供一个参考答案: 8 | > **网络接口层**:这是协议栈的最低层,对应OSI的物理层和数据链路层,主要完成数据帧的实际发送和接收。 9 | **网络层**:处理分组在网络中的活动,例如路由选择和转发等,这一层主要包括IP协议、ARP、ICMP协议等。 10 | **传输层**:主要功能是提供应用程序之间的通信,这一层主要是TCP/UDP协议。 11 | **应用层**:用来处理特定的应用,针对不同的应用提供了不同的协议,例如进行文件传输时用到的FTP协议,发送email用到的SMTP等。 12 | 13 | ####数据库:#### 14 | - 事务的几个特性(含义+举例说明)。 15 | - 用MySQL语法建 一个学生表,包括学生姓名、性别、年龄、班级信息。 16 | - char()与varchar()的区分,什么情况下用char()?(两者区别很重要) 17 | - 建过索引吗?什么情况下需要建立索引? 18 | - 索引的作用?为什么能够提高查询速度?(索引的原理) 19 | - 索引有什么副作用吗? 20 | - 在sql语句中加上字符集的方法。 21 | 22 | ####C语言#### 23 | - sizeof使用相关 24 | ```cpp 25 | struct Test { 26 | int a; 27 | char b; 28 | short c; 29 | }; 30 | ``` 31 | 问: 32 | sizeof(Test)=? 33 | Test test; 34 | sizeof(test)=? 35 | 36 | - static关键字作用(区分C语言和C++,两种语言下作用有所不同)。 37 | - volatile关键字的作用。 38 | 39 | ####Linux:#### 40 | 会Linux开发吗?会shell脚本吗?比如grep、awk,然后给了一个实用场景,让用grep或awk进行文本处理。 41 | 42 | ####编程题:#### 43 | 求一个单链表的中间节点,要求安全检查,能直接运行的程序。(很简单,但能写出无bug、完全能运行的程序也不是非常容易,要注意边界检查、指针是否为空、特殊情况、编码风格、是否有注释等)。 44 | 45 | ##附:同学的面试题## 46 | 47 | ![6{O}ZG`SBUKLS0)C1_7N)R2.jpg](http://upload-images.jianshu.io/upload_images/46178-6feda037449f1167.jpg) -------------------------------------------------------------------------------- /Microsoft/src/BeautifulString.java: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | import java.io.StreamTokenizer; 3 | 4 | public class BeautifulString { 5 | public static void main(String[] args) throws IOException { 6 | 7 | StreamTokenizer st = new StreamTokenizer(System.in); 8 | while (st.nextToken() != StreamTokenizer.TT_EOF) { 9 | int n = (int) st.nval; 10 | for (int i = 0; i < n; i++) { 11 | st.nextToken(); 12 | int m = (int) st.nval; 13 | st.nextToken(); 14 | String str = st.sval; 15 | isBeautifulString(str.toCharArray(), m); 16 | } 17 | } 18 | 19 | } 20 | 21 | static void isBeautifulString(char str[], int len) { 22 | int i = 0, j; 23 | int count = 1, totalCount = 1, lastCount = 0; 24 | while (i < len - 1) { 25 | if (str[i + 1] == str[i] + 1) { 26 | if (lastCount != 0 && lastCount != count) { 27 | i++; 28 | count = 1; 29 | totalCount = 1; 30 | lastCount = 0; 31 | continue; 32 | } 33 | lastCount = count; 34 | count = 1; 35 | totalCount++; 36 | } else if (str[i + 1] == str[i]) { 37 | count++; 38 | } else { 39 | count = 1; 40 | totalCount = 1; 41 | lastCount = 0; 42 | } 43 | if (totalCount > 2) { 44 | System.out.println("YES"); 45 | return; 46 | } 47 | i++; 48 | } 49 | 50 | System.out.println("NO"); 51 | } 52 | } -------------------------------------------------------------------------------- /360/2014-360校园招聘技术类面试题.md: -------------------------------------------------------------------------------- 1 | 建议首选看(有些面试题根据笔试题而来): 2 | ## [2014 360校园招聘技术类笔试题](http://blog.csdn.net/lanxuezaipiao/article/details/41892553) 3 |

4 |

5 | ### 面试题 6 | 1. 对于: 7 | const char *p = "Hello World"; 8 | char p[] = "Hello World"; 9 | 分别求长度和所占用空间大小。 10 | 11 | **提示**:求长度都可以用strlen(p),求占内存空间大小第一个不能用sizeof,第二个可以用sizeof。 12 | 另外,第二个:strlen(p) = 11, sizeof(p) = 12 13 | 14 | 2. 给定一个正整数n,将其分成m段,每段为n1,n2,...,nm,求怎么划分使得n1\*n2\*...\*nm最大。 15 | 16 | 3. 给一个数组a和长度len,删除其中的负数并保证数组中原数据相对次序不变。 17 | 函数原型:void removeNegative(int *a, size_t len); 18 | 19 | 4. 进程通信有哪几种方式?选两种你最熟悉的方式进行具体讲解。 20 | 我选了共享内存来说,然后接着问两个进程怎么通过共享内存进行通信?(进程间可以共享栈吗?) 21 | 22 | 5. 针对笔试题的扩展:求一个数组中的第k大的数。 23 | 24 | 6. 针对笔试题的最后一道编程题,我写的代码有哪些缺陷? 25 | 26 | **提示**:(1)注意健壮性,比如判断数组a是否为null,数组长度是否为0和1; 27 | (2)注意特殊情况和边界情况,如果数组为3, 3, 2, 1,那么你的代码求出的第二大的数为3但正确答案为2,怎么修改使其正确。 28 | 29 | 7. web测试需要测试哪些方面?举例,比如上传一个大文件Tomcat会崩溃啥的。 30 | 31 | 8. Java中的设计模式,写个单例模式,解释工厂模式的作用。 32 | 33 | 9. get和post的区别?知道重定向吗?有哪些分类(提示说临时重定向和永久重定向)。 34 | 35 | 10. 堆、栈和全局区都存放些什么内容? 36 | 37 | 11. 下面这两句有啥问题吗? 38 | ```java 39 | public class A { 40 | int a = 2; 41 | int b = a + 3; 42 | } 43 | ``` 44 | **提示**:面试官说在Eclipse下有个提示,提示将a作为静态变量,因为b引用了类中的a而非对象a(为什么我的Eclipse下没警告提示???) 45 | 46 | 12. 写代码:从源路径中读取一个文件,写入到目标路径文件中。 47 | 48 | 13. try{}…catch{}…finally{}机制 49 | **提示**:在try中遇到运行时异常时(例如除0操作等)或调用System.exit(1)等导致I/O直接中断,此时不会去运行finally里的语句,异常分类 50 | 51 | 14. struts2与struts1的区别,ssh的作用。 52 | 53 | 15. MapReduce的工作机制,里面的排序算法用的是什么(快速排序?) 54 | 55 | 16. 写过多少行代码?怎么算出来的? 56 | 57 | 17. 怎么比较自己所拿到的几个offer(工作地点、工作环境、职位发展前景、待遇)。 58 | 59 | 18. 知道回调函数吗?举个回调函数的使用场景。 60 | 61 | 19. new和malloc都是堆分配,malloc后返回一个地址例如为p,如果p++后再free(p),是否会出问题? 62 | **提示**:会,丢失了释放的一些具体信息,如释放内存大小等。 -------------------------------------------------------------------------------- /Baidu/百度2015校园招聘面试题回忆录(成功拿到offer).md: -------------------------------------------------------------------------------- 1 | # 引言 2 | 3 | 盼望着,盼望着……今年终于轮到我找工作了,还深深记得去年跟在师兄后面打各种酱油的经历,当时觉得找工作好难啊,怎么面一个败一个,以后还能找到工作不? 4 | 5 | 不过当时的失败也是理所当然的,那时候没有做任何准备(连进程间有几种通信方式这样老掉牙的题我都不知道),没有任何找工作的经验,甚至一个简单的自我介绍都吞吞吐吐的。 6 | 7 | 经过一年时间的磨练,特别是近几个月的强度知识吸收,感觉个人在能力和知识储备方面有了质的提高,这大大提高了我的自信心,也让我在这个秋季的求职生涯最终以较满意收场。 8 | 9 | 截止目前为止,找工作总算告一段落。初次找工作,只投了前面的几家公司(有百度、阿里、美团、搜狗、华为等),今年比较幸运,面的几家公司都成功拿到offer,也算是初战告捷。这些公司的招聘结束后我就没再参加后面的一些大型互联网公司了,比如奇虎360、网易、爱奇艺、金山等等,不像我的一些同学,手里offer多的都拿不动了,也有满意的了,可还是满怀干劲的参加后面的招聘,真心不知道他们的精力和耐力从何而来,可能是他们想成为传说中的offer帝和面霸吧。我个人无喜于那些称谓,既然有了较满意的offer就不想再耗费太多的精力去争根本不会考虑的offer,也可能是自己的惰性所为…… 10 | 11 | OK,废话到此为止,下面简单回顾下自己在百度面试过程中的一些题目,给还在找工作或将来要找工作的同学一个浅薄的参考。 12 | 13 | - - - 14 | 15 | # 百度面试题 16 | 17 | 一面(1 hour): 18 | 19 | > 1.面试官从简历里抽了一个较感兴趣的项目,让把项目简单介绍了下,针对项目问了几个技术问题 20 | > 2. 介绍Java中垃圾回收机制,程序员平时需要关注这个吗?为什么?请举例说明。 21 | > 3. 数据库隔离级别介绍、举例说明。 22 | > 4. override和overload的区别。 23 | > 5. 求二叉树的最大距离(即相距最远的两个叶子节点),写代码。 24 | > 6. 两个栈实现一个队列,写代码。 25 | > 7. 你觉得你的优势是什么?有什么技术薄弱点吗? 26 | > 8. 目前手上有offer吗? 27 | 28 | 二面(40 minutes): 29 | 30 | > 1.详细介绍研究生期间的小论文项目。 31 | > 2. 求二叉树的宽度,先简介思路再写代码。 32 | > 3. Hashmap、Hashtable和cocurrentHashMap的区别,要讲出它们各自的实现原理才行,比如Hashmap的扩容机制、cocurrentHashMap的桶分割原理、多线程安全性。 33 | > 4. 进程调度算法,有哪些算法比较难实现? 34 | > 5. linux下如何修改进程优先级?(nice命令的使用)。 35 | > 6. linux下性能监控命令uptime介绍,平均负载的具体含义是什么?建议看server load概念。 36 | > 7. linux下如何调试程序?说到gdb,具体如何调试?如何查看core文件中的堆栈信息等(bt指令)。 37 | 38 | 三面(1 hour and twenty minutes): 39 | 40 | > 1.介绍我研究生期间的论文,讲的很详细,每个点具体采用的技术、实现方法等,花了较长时间。 41 | > 2. 打印二叉树两个叶子节点间的路径,写代码(汗,百度这么喜欢问二叉树)。 42 | > 3. 字符串中第一个只出现一次的字符,如何优化算法使得遍历次数更少? 43 | > 4. socket编程相关,如果服务器这边调用write写了100个字节的数据,客户端想要获得这个数据,是直接用read系统调用,参数也是100吗? 44 | > 5. 百度新闻缓存预算问题:一般为了追求时间性能,都需要缓存一些新闻数据,你怎么计算所需预算?然后申请需要的主机…… 45 | > 6. 多线程的适用场景是什么?为啥要用多线程? 46 | > 7. 问是否会go语言,…… 47 | > 8. 为啥对技术感兴趣,一些相关问题讨论。 48 | > 9. 聊北京、谈offer。 49 | 50 | > 最后面试官说像计算机体系结构、操作系统这样的书一定要看国外的,国内的有时候会误导人。 51 | 52 | - - - 53 | 54 | # 总结 55 | 56 | 三面都是技术面,总体下来没有特别难的题目,从我的面试情况来看,百度这次非常看重面试者对二叉树的掌握情况,还有所做的项目详细介绍。后面我会继续分享自己在面试过程中的一些个人经验和技巧。 57 | 58 | 59 | published from :[百度2015校园招聘面试题回忆录(成功拿到offer)](http://blog.csdn.net/lanxuezaipiao/article/details/40054675) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | IT-Interviews-Sharing 2 | ===================== 3 | 4 | Sharing many well-known companies' Interview questions during my preparation for job. These companies include Microsoft, alibaba, baidu, tecent, sogou, 360, youku and so on. Most interview questions have detailed answers and skills. 5 | 6 | 分享我在准备找工作期间参与的一些知名公司的笔试面试题。这些公司包括微软、阿里巴巴、百度、腾讯、搜狗、奇虎360、优酷等等,大部分笔试题和面试题都有详细分析解答和面试技巧分享。 7 | 8 | **PS**: 9 | >1. 请随时关注我的CSDN关注“[敏敏笔试面试分享](http://blog.csdn.net/column/details/it-interview.html)”,最新的资料会及时更新。 10 | 11 | >2.下面的内容目前都发表在博客里,有些内容已经用markdown格式重新整理存放到该github目录下,但更多的内容没有整理进来。希望有一些热心的contributors能够参与进这个项目,将博客内容重新用markdown格式整理进github,方便大家更方便的查看和一次性clone到本地存储。 12 | 13 | ##目录 14 | ### 面试题 15 | 1. [阿里2015校招面试回忆录(成功拿到offer)](http://blog.csdn.net/lanxuezaipiao/article/details/40184329) 16 | 17 | 2. [百度2015校园招聘面试题回忆录(成功拿到offer)](http://blog.csdn.net/lanxuezaipiao/article/details/40054675) 18 | 19 | 3. [2014腾讯实习一面面试题](http://blog.csdn.net/lanxuezaipiao/article/details/41594745) 20 | 21 | 4. [2014 360校园招聘技术类面试题](http://blog.csdn.net/lanxuezaipiao/article/details/41892637) 22 | 23 | ### 笔试题 24 | 1. [百度2014研发类校园招聘笔试题解答](http://www.cnblogs.com/lanxuezaipiao/p/3356624.html) 25 | 26 | 2. [优酷土豆2014校园招聘笔试题目之Java开发类](http://www.cnblogs.com/lanxuezaipiao/p/3339603.html) 27 | 28 | 3. [2014 360校园招聘技术类笔试题](http://blog.csdn.net/lanxuezaipiao/article/details/41892553) 29 | 30 | 4. [2015美团校招部分笔试题](http://blog.csdn.net/lanxuezaipiao/article/details/41774539) 31 | 32 | 5. [2015 CVTE校招网测部分试题(技术类)](http://blog.csdn.net/lanxuezaipiao/article/details/41777565) 33 | 34 | 6. [2014木瓜移动校园招聘笔试题之递归优化题解答](http://blog.csdn.net/lanxuezaipiao/article/details/38824813) 35 | 36 | 7. [搜狗2013年校园招聘研发类笔试试卷之C/C++类](http://www.cnblogs.com/lanxuezaipiao/p/3185146.html) 37 | 38 | ### 笔试面试总结知识点 39 | 1. [精选30道Java笔试题解答](http://blog.csdn.net/lanxuezaipiao/article/details/16753743) 40 | 41 | 2. [C/C++求职宝典21个重点笔记(常考笔试面试点)](http://blog.csdn.net/lanxuezaipiao/article/details/41557307) 42 | 43 | 3. [10道C++输出易错笔试题收集(敢进来挑战吗?)](http://blog.csdn.net/lanxuezaipiao/article/details/41774829) 44 | 45 | 4. [常问面试题:C++中sizeof的陷阱及应答](http://blog.csdn.net/lanxuezaipiao/article/details/19013833) 46 | 47 | 5. [面试题之发散思维能力:如何用非常规方法求1+2+···+n](http://blog.csdn.net/lanxuezaipiao/article/details/19086179) 48 | 49 | 6. [常见笔试面试题:实现一个递增排序的单链表](http://blog.csdn.net/lanxuezaipiao/article/details/20409759) 50 | 51 | 7. [程序员求职面试心经40条——谨记原则](http://blog.csdn.net/lanxuezaipiao/article/details/18887869) 52 | 53 | 8. [最难面试的IT公司之ThoughtWorks代码挑战——FizzBuzzWhizz游戏](http://blog.csdn.net/lanxuezaipiao/article/details/24989879) -------------------------------------------------------------------------------- /Microsoft/src/CombinationLock.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.util.StringTokenizer; 3 | 4 | public class CombinationLock { 5 | public static void main(String[] args) { 6 | 7 | Scanner in = new Scanner(System.in); 8 | while(in.hasNext()) { 9 | int n, m; 10 | // int n = 7; 11 | // int m = 4; 12 | // String lock = "ABCDEFG"; 13 | // steps[0] = "CMD 1 2 5 C"; 14 | // steps[1] = "CMD 2 3 7 4"; 15 | // steps[2] = "CMD 3 3"; 16 | // steps[3] = "CMD 4 1 7"; 17 | 18 | String nm = in.nextLine(); 19 | StringTokenizer st = new StringTokenizer(nm, " "); 20 | n = Integer.parseInt(st.nextToken()); 21 | m = Integer.parseInt(st.nextToken()); 22 | // System.out.println(n + " " + m); 23 | String lock = in.nextLine(); 24 | // System.out.println("lock: " + lock); 25 | 26 | String[] steps = new String[m]; 27 | for(int i = 0; i < m; i++) { 28 | steps[i] = in.nextLine(); 29 | // System.out.println("steps[" + i + "]: " + steps[i]); 30 | } 31 | 32 | openCombinationLock(lock.toCharArray(), n, steps, m); 33 | } 34 | 35 | } 36 | 37 | static void openCombinationLock(char[] lock, int n, String[] steps, int m) { 38 | int cmd; 39 | String args; 40 | for(int i = 0; i < m; i++) { 41 | cmd = steps[i].charAt(4) - '0'; 42 | args = steps[i].substring(6); 43 | // System.out.println(cmd + ": " + args); 44 | handleCMD(lock, n, cmd, args); 45 | // System.out.println(new String(lock)); 46 | } 47 | System.out.println(new String(lock)); 48 | } 49 | 50 | static void handleCMD(char[] lock, int n, int cmd, String args) { 51 | StringTokenizer st = new StringTokenizer(args, " "); 52 | int i, j, k, index; 53 | char x; 54 | switch(cmd) { 55 | case 1: 56 | i = Integer.valueOf(st.nextToken()); 57 | j = Integer.valueOf(st.nextToken()); 58 | x = st.nextToken().charAt(0); 59 | for(index = i - 1; index < j; index++) { 60 | lock[index] = x; 61 | } 62 | break; 63 | case 2: 64 | i = Integer.valueOf(st.nextToken()); 65 | j = Integer.valueOf(st.nextToken()); 66 | k = Integer.valueOf(st.nextToken()); 67 | for(index = i - 1; index < j; index++) { 68 | lock[index] = (char) (lock[index] + k); 69 | if(lock[index] > 90) 70 | lock[index] = (char) (lock[index] - 91 + 65); 71 | } 72 | break; 73 | case 3: 74 | k = Integer.valueOf(st.nextToken()); 75 | reverse(lock, 0, k - 1); 76 | reverse(lock, k, n - 1); 77 | reverse(lock, 0, n - 1); 78 | break; 79 | case 4: 80 | i = Integer.valueOf(st.nextToken()); 81 | j = Integer.valueOf(st.nextToken()); 82 | if(i <= j) { 83 | handleCMD(lock, n, 4, i + 1 + " " + j); 84 | handleCMD(lock, n, 2, i + " " + j + " " + 1); 85 | } 86 | break; 87 | } 88 | 89 | } 90 | 91 | static void reverse(char[] str, int left, int right) { 92 | for(int i = left, j = right; i < j; i++, j--) { 93 | char tmp = str[i]; 94 | str[i] = str[j]; 95 | str[j] = tmp; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /Microsoft/src/PerformanceLog.java: -------------------------------------------------------------------------------- 1 | import java.text.ParseException; 2 | import java.text.SimpleDateFormat; 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | import java.util.Scanner; 7 | import java.util.StringTokenizer; 8 | 9 | public class PerformanceLog { 10 | public static void main(String[] args) { 11 | Scanner in = new Scanner(System.in); 12 | PerformanceLog main = new PerformanceLog(); 13 | while(in.hasNext()) { 14 | String num = in.nextLine(); 15 | int len = Integer.valueOf(num); 16 | String logs[] = new String[len]; 17 | /* logs[0] = "FuncA 00:00:01 START"; 18 | logs[1] = "FuncB 00:00:02 START"; 19 | logs[2] = "FuncC 00:00:03 START"; 20 | logs[3] = "FuncA 00:00:04 END"; 21 | logs[4] = "FuncB 00:00:05 END"; 22 | logs[5] = "FuncD 00:00:06 START"; 23 | logs[6] = "FuncD 00:00:07 END"; 24 | logs[7] = "FuncC 00:00:08 END";*/ 25 | 26 | 27 | for(int i = 0; i < len; i++) { 28 | logs[i] = in.nextLine(); 29 | } 30 | main.LogAnalysis(logs, len); 31 | } 32 | } 33 | 34 | String getTime(String t1, String t2) { 35 | Date d1 = null; 36 | Date d2 = null; 37 | 38 | SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss"); 39 | 40 | try{ 41 | d1 = sdf.parse(t1); 42 | d2 = sdf.parse(t2); 43 | } catch (ParseException pe) { 44 | System.out.println("error"); 45 | } 46 | if(d2.getTime() > d1.getTime()) System.out.println("Incorrect performance log"); 47 | Date d = new Date(d1.getTime() - d2.getTime()); 48 | char strs[] = sdf.format(d).toCharArray(); 49 | strs[0] = '0'; 50 | strs[1] = '0'; 51 | 52 | return new String(strs); 53 | } 54 | 55 | void LogAnalysis(String[] logs, int len) { 56 | StringTokenizer st; 57 | List logList = new ArrayList(len); 58 | List results = new ArrayList(len); 59 | boolean flag; 60 | for(int i = 0; i < len; i++) { 61 | flag = false; 62 | st = new StringTokenizer(logs[i], " "); 63 | String funcName = st.nextToken(); 64 | String time = st.nextToken(); 65 | String action = st.nextToken(); 66 | Log lg = new Log(funcName, time, action); 67 | // System.out.println(funcName + ":" + time + ":" + action); 68 | for(Log log : logList) { 69 | if(funcName.equals(log.funcName)) { 70 | flag = true; 71 | if(funcName.equals(logList.get(logList.size() - 1).funcName)) { 72 | if(!action.equals("END") || !logList.get(logList.size() - 1).action.equals("START")) { 73 | System.out.println("Incorrect performance log"); 74 | return; 75 | } 76 | String t1 = lg.timeStamp; 77 | String t2 = logList.get(logList.size() - 1).timeStamp; 78 | // System.out.println("t1: " + t1 + "; t2: " + t2); 79 | for(Log l : results) { 80 | if(l.funcName.equals(funcName)) { 81 | l.result = getTime(t1, t2); 82 | break; 83 | } 84 | } 85 | // System.out.println(funcName + " " + getTime(t1, t2)); 86 | logList.remove(logList.size() - 1); 87 | } else { 88 | System.out.println("Incorrect performance log"); 89 | return; 90 | } 91 | break; 92 | } 93 | } 94 | if(!flag) { 95 | logList.add(lg); 96 | results.add(lg); 97 | } 98 | } 99 | 100 | for(Log log : results) { 101 | System.out.println(log.funcName + " " + log.result); 102 | } 103 | } 104 | 105 | class Log { 106 | public String funcName; 107 | public String timeStamp; 108 | public String action; 109 | public String result; 110 | 111 | public Log(String funcName, String timeStamp, String action) { 112 | this.funcName = funcName; 113 | this.timeStamp = timeStamp; 114 | this.action = action; 115 | } 116 | } 117 | 118 | } -------------------------------------------------------------------------------- /Microsoft/src/StringMatchingContentLength.java: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | import java.util.Scanner; 3 | 4 | public class StringMatchingContentLength { 5 | public static void main(String[] args) throws IOException { 6 | 7 | Scanner in = new Scanner(System.in); 8 | while(in.hasNext()) { 9 | String strA = in.nextLine(); 10 | String strB = in.nextLine(); 11 | // String strA = "abcdefghijklmn"; 12 | // String strB = "ababceghjklmn"; 13 | int[] index1 = new int[strA.length() / 3]; 14 | int[] index2 = new int[strB.length() / 3]; 15 | int[] length = new int[strB.length()]; 16 | int kth = 0; 17 | kth = getStringMatchLenth(strA.toCharArray(), strB.toCharArray(), index1, index2, length, kth); 18 | // System.out.println("kth: " + kth); 19 | // for(int i = 0; i < kth; i++) 20 | // System.out.print(index1[i] + " "); 21 | // System.out.println(); 22 | // for(int i = 0; i < kth; i++) 23 | // System.out.print(index2[i] + " "); 24 | // System.out.println(); 25 | // for(int i = 0; i < kth; i++) 26 | // System.out.print(length[i] + " "); 27 | // System.out.println(); 28 | int tmp; 29 | for(int i = 0; i < kth - 1; i++) { 30 | for(int j = 0; j < kth - i - 1; j++) { 31 | if(index1[j] > index1[j + 1]) { 32 | tmp = index1[j]; 33 | index1[j] = index1[j + 1]; 34 | index1[j + 1] = tmp; 35 | tmp = index2[j]; 36 | index2[j] = index2[j + 1]; 37 | index2[j + 1] = tmp; 38 | tmp = length[j]; 39 | length[j] = length[j + 1]; 40 | length[j + 1] = tmp; 41 | } 42 | } 43 | } 44 | int maxLen = length[0]; 45 | int i = 1, last = 0; 46 | while(i < kth) { 47 | if(index2[i] > index2[last]) { 48 | maxLen += length[i]; 49 | last = i; 50 | } 51 | i++; 52 | } 53 | System.out.println(maxLen); 54 | } 55 | 56 | } 57 | 58 | static int getStringMatchLenth(char[] str1, char[] str2, int[] index1, int[] index2, int[] length, int kth) { 59 | int len1, len2; 60 | len1 = str1.length; 61 | len2 = str2.length; 62 | int maxLen = len1 > len2 ? len1 : len2; 63 | 64 | int[] max = new int[maxLen];// 保存最长子串长度的数组 65 | int[] maxIndex1 = new int[maxLen];// 保存最长子串长度最大索引的数组 66 | int[] maxIndex2 = new int[maxLen]; 67 | int[] c = new int[maxLen]; 68 | 69 | int i, j; 70 | for (i = 0; i < len2; i++) { 71 | for (j = len1 - 1; j >= 0; j--) { 72 | if (str2[i] == str1[j]) { 73 | if ((i == 0) || (j == 0)) 74 | c[j] = 1; 75 | else 76 | c[j] = c[j - 1] + 1;// 此时C[j-1]还是上次循环中的值,因为还没被重新赋值 77 | } else { 78 | c[j] = 0; 79 | } 80 | 81 | // 如果是大于那暂时只有一个是最长的,而且要把后面的清0; 82 | if (c[j] > max[0]) { 83 | max[0] = c[j]; 84 | maxIndex1[0] = j; 85 | maxIndex2[0] = i; 86 | 87 | for (int k = 1; k < maxLen; k++) { 88 | max[k] = 0; 89 | maxIndex1[k] = 0; 90 | maxIndex2[k] = 0; 91 | } 92 | } 93 | // 有多个是相同长度的子串 94 | else if (c[j] == max[0]) { 95 | for (int k = 1; k < maxLen; k++) { 96 | if (max[k] == 0) { 97 | max[k] = c[j]; 98 | maxIndex1[k] = j; 99 | maxIndex2[k] = i; 100 | break; // 在后面加一个就要退出循环了 101 | } 102 | } 103 | } 104 | } 105 | } 106 | // 打印最长子字符串 107 | for (j = 0; j < 1; j++) { 108 | if (max[j] > 0) { 109 | if(max[j] < 3) return kth; 110 | // System.out.println("第" + (j + 1) + "个公共子串:" + max[j]); 111 | length[kth] = max[j]; 112 | i = maxIndex1[j] - max[j] + 1; 113 | index1[kth] = i; 114 | for (; i <= maxIndex1[j]; i++) 115 | str1[i] = '0'; 116 | i = maxIndex2[j] - max[j] + 1; 117 | index2[kth] = i; 118 | for (; i <= maxIndex2[j]; i++) 119 | str2[i] = '1'; 120 | // System.out.println(new String(str1)); 121 | // System.out.println(new String(str2)); 122 | 123 | kth = getStringMatchLenth(str1, str2, index1, index2, length, kth + 1); 124 | } 125 | } 126 | return kth; 127 | } 128 | 129 | } -------------------------------------------------------------------------------- /360/2014-360校园招聘技术类笔试题.md: -------------------------------------------------------------------------------- 1 | 接下来的面试题传送门: 2 | ## [2014 360校园招聘技术类面试题](http://blog.csdn.net/lanxuezaipiao/article/details/41892637) 3 |

4 |

5 | 6 | ### 选择题 7 | 1. 小毕最近电脑很慢,怀疑是中了病毒,于是找了三款杀毒软件扫描了一下: 8 | >A软件扫描结果:如果中了病毒X,那么也可能中了病毒Y 9 | B软件扫描结果:如果没有中病毒X,那么一定中了病毒Y 10 | C软件扫描结果:中了病毒X 11 | 12 | 小毕不知道该相信哪个,于是找360技术支持,360技术支持告诉他只有一个软件的扫描结果是正确,那么请推断:() 13 | A 中了病毒X 14 | B 中了病毒Y 15 | C 两个病毒都中了 16 | D 两个都没中 17 | 18 | 2. 一个富人雇1人为他做七天工,他给他的工钱是毗邻在一起的七块金条(天天一块),要保证天天雇工拿到他应拿工钱(不能多也不能少),富人只能掰断二次连在一起的金条,问:最少掰断几次能做到按要求给雇工报酬() 19 | A. 2   B .3   C. 4   D .7 20 | 21 | 3. 某学校有四名外国专家,分别来自美国、加拿大、韩国和日本。他们分别在电子、机械 22 | 和生物三个系工作,其中: 23 | ① 日本专家单独在机械系; 24 | ② 韩国专家不在电子系; 25 | ③ 美国专家和另外某个外国专家同在某个系; 26 | ④ 加拿大专家不和美国专家同在一个系。 27 | 以上条件可以推出美国专家所在的系为 (D) 28 | (A) 电子 29 | (B) 机械系 30 | (C) 生物系 31 | (D) 电子系或生物系 32 | 33 | 4. 五对夫妇甲乙丙丁戊聚会,见面是互相握手问候,每个人都可以和其他人握手,但夫妇之间不能握手,甲先生好奇地私下问每个人(包括他太太)打听刚才握手的次数,得到的回答是:0,1, 2,3,4,5,6,7,8,文甲太太握手( )次。 34 | A. 3   B. 4   C. 5   D. 6 35 | 36 | 5. 甲、乙、丙、丁四个人,一个是教师,一个是售货员,一个是工人,一个是老板。请你根据下面的情况判断每个人的职业。 37 | (1) 甲和乙是邻居,每天一起骑车去上班 38 | (2) 甲比丙年龄大 39 | (3) 甲和丁业余炼武术 40 | (4) 教师每天步行上班 41 | (5) 售货员的邻居不是老板 42 | (6) 老板和工人互不相识 43 | (7) 老板比售货员和工人年龄都大 44 | 45 | 6. 某商店以60元同时卖出两件商品,已知其中一件赚20%,另一件亏20%,那么这个商店卖出这两件商品是赚了() 46 | A -10   B 5   C -5  D 0 47 | 48 | 7. 某城市发生了一起汽车撞人逃跑事件,该城市只有两种颜色的车,蓝色15% 绿色85%,事发时有一个人在现场看见了,他指证是蓝车。 49 | 但是根据专家在现场分析,当时那种条件能看正确的可能性是80% 50 | 那么,肇事的车是蓝车的概率到底是多少() 51 | A 12%   B 21%  C 41%   D 80% 52 | 53 | 8. X是类名称,下面哪个写法是错误的() 54 | A const X \* x  B X const \* x   C const X const \*x  D X \* const x 55 | 56 | 9. 下面输出什么?() 57 | ```cpp 58 | #include 59 | void main() 60 | { 61 | for(int a = 1, b = 1; a <= 100; a++) 62 | { 63 | if(b >= 20) break; 64 | b += 3; 65 | } 66 | b = b - 5; 67 | printf("%d\n", a); 68 | } 69 | ``` 70 | A 6  B 7   C 8   D 9 71 | 72 | 10. 下面说法正确的是() 73 | for(int i = 0, k = 1; k = 0; i++, k++) 74 | A 判断循环的条件不合法 75 | B 陷入无限循环 76 | C 循环一次也不执行 77 | D 循环只执行一次 78 | 79 | 11. 假设指针变量p定义为:int \*p = new int[100],下面释放p所执行内存的操作中正确的是() 80 | A delete p  B delete \*p  C delete &p  D delete []p 81 | 82 | 12. 选择填空() 83 | ```cpp 84 | #include 85 | void test(void *data) 86 | { 87 | unsigned int value = 填空处; 88 | printf("%d\n", value); 89 | } 90 | void main() 91 | { 92 | unsigned int data = 10; 93 | test(&data); 94 | } 95 | ``` 96 | A \*data   B (unsigned int) \*data 97 | C (unsigned \*)data   D \*(unsigned int \*)data 98 | 99 | 13. 在C++中下面哪个可以成为对象继承之间的转换() 100 | A static_cast   B dynamic_cast  C const_static  D reinterpret_cast 101 | 102 | 14. 下面程序的输出结果是() 103 | ```cpp 104 | A *pa = new A(); 105 | pa->f(); 106 | B *pb = (B*)pa; 107 | pb->f(); 108 | delete pa, pb; 109 | pa = new B(); 110 | pa->f(); 111 | pb = (B*)pa; 112 | pb->f(); 113 | ``` 114 | A. AABA   B. AABB  C. AAAB  D. ABBA 115 | 116 | 15. 辗转相除法求两个非负整数之间的最大公约数() 117 | ```cpp 118 | long long gcd(long long x, long long y) 119 | { 120 | if(y == 0) return 0; 121 | else return gcd(y, x % y); 122 | } 123 | ``` 124 | 假设x和y中较大的数长度为n,则此算法的时间复杂度是(B) 125 | A O(1)  B O(lgn)   C O(n)   D O(n ^ 2) 126 | 127 | 16. 进程间通讯方式中哪种访问速度最快?() 128 | A 管道  B消息队列   C 共享内存  D 套接字 129 | 130 | 17. TCP关闭过程中,正确的是() 131 | A、处于TIME_WAIT状态的链接等待2MSL后真正关闭链接 132 | B、对一个established状态的TCP连接,在调用shutdown函数之前调用close接口,可以让主动调用的一方进入半关闭状态 133 | C、主动发送FIN消息的连接端,收到对方回应ack之前不能发只能收,在收到对方回复ack之后不能发也不能收,进入CLOSING状态 134 | D、在已经成功建立连接的TCP连接上,任何情况下都不允许丢失数据。 135 | 136 | 18. 下列说法错误的是() 137 | A、单线程异步非阻塞模式通常在单核CPU情况下能够比多线程更充分利用资源 138 | B、采用锁来访问现场共享资源时,如果加锁和解锁操作处在同一个线程中,则不会导致死锁 139 | C、一个程序枝梢有一个进程,一个进程至少有一个线程 140 | D、一个同步方法是一段时间内只允许一个线程进入执行 141 | 142 | 19. **代码生成阶段的主要任务**是(把中间代码变换成依赖具体机器的目标代码)。 143 | 144 | 20. 词法分析器用来识别(C ) 145 | A 句子  B 句型   C 单词  D 生产式 146 | 147 | 21. 下列哪一个可以作为对象继承之间的转换(A) 148 | A static_cast   B dynamic_cast   C const_cast   D reinterpret_cast 149 | 150 | 22. 下列说法中,哪个是错误的(C) 151 | A、若进程A和进程B在临界段上互斥,那么当进程A处于该临界段时,它不能被进程B中断 152 | B、虚拟存储管理中采用对换策略后,用户进程可使用的存储空间似乎增加了 153 | C、虚拟存储管理中的抖动现象是指页面置换时用于换页的时间大于程序执行时间 154 | D、进程可以由程序、数据和进程控制块描述 155 | 156 | 23. 操作系统采用分页式存储管理中,要求(B) 157 | A、每个进程拥有一张页表,且进程的页表驻留在内存中 158 | B、每个进程拥有一张页表,但只要执行进程的页表驻留在内存中,其他进程的页表不必驻留在内存中 159 | C、所有进程共享一张页表,以节约有限的内存空间,但页表必须驻留在内存中 160 | D、所有进程共享一张页表,只有页表中当前使用的页面必须驻留在内存中,以最大限度的节约有限的内存空间 161 | 162 | 24. linux中调用write发送网络数据返回n(n > 0)表示() 163 | A 对方已收到n个字节 164 | B 本地已发送n个字节 165 | C 系统网络buff已收到n个字节 166 | D 系统调用失败 167 | 168 | 25. HTTP应答中的500错误是指() 169 | A 服务器内部错误   B 文件未找到   C 客户端网络不通   D 没有访问权限 170 | 171 | 27. 根据自己的理解描述下Android数字签名。 172 | 答:(1)所有的应用程序都必须有数字证书,Android系统不会安装一个没有数字证书的应用程序 173 | (2)Android程序包使用的数字证书可以是自签名的,不需要一个权威的数字证书机构签名认证 174 | (3)如果要正式发布一个Android ,必须使用一个合适的私钥生成的数字证书来给程序签名,而不能使用adt插件或者ant工具生成的调试证书来发布。 175 | (4)数字证书都是有有效期的,Android只是在应用程序安装的时候才会检查证书的有效期。如果程序已经安装在系统中,即使证书过期也不会影响程序的正常功能。 176 | 177 | 28. 如何判断大小端? 178 | big endian(大端法)是指低地址存放最高有效字节(MSB),而little endian(小端法)则是低地址存放最低有效字节(LSB)。 179 | ```cpp 180 | #include 181 | using namespace std; 182 | int main() 183 | { 184 | unsigned int a = ~0; 185 | if( a>65536 ) 186 | { 187 | cout<<"32 bit"< 由于我面的是Java开发,但当时负责人员给我安排了一个C++面试官(在面试官桌子上放着一个“C++方向”的牌子),然后我就跟负责人说“我是面Java方向的,不是C++方向的”,结果那个面试官笑呵呵的说“没关系,在我这面一样的,如果你不懂C++,我可以不问你C++语言方面的细节问题”,当时我心里想:虽然我C++学的和Java差不多,就算面C++也没有问题。但是既然面试官这么说了,肯定不问C++了,Java估计也不会问(C++方向的工程师不一定懂Java呢),应该是问数据结构、算法、网络、操作系统方面的问题了。虽然都有所准备,面起来也可以,但是鉴于两个方面的原因,我还是没答应在这面。 12 | (1)据说阿里90%都是招Java工程师,如果在这面后面肯定会以为我是面C++的,胜算就少了; 13 | (2)我这几个月基本上都在专研Java方向的知识,也研究了不少JDK源码和Java相关的项目,感觉自己的Java方向知识有了一个质的提高,因此希望面试官能够考查和检验我这方面的知识。 14 | 15 | >因此我当时跟那个面试官说“不好意思,我还是希望能面Java方向的知识”,那个面试官依旧笑呵呵“如果你对Java知识的确非常自信,那么可以给你换个Java方向的面试官”,然后我只能说“是的,我有研究过很多JDK源码,也做了不少Java项目”。最后,我出去找负责人给我安排Java方向的面试官,负责人说“那你要等会儿才行,估计要半个小时”。“哦,没关系,那我等会吧”,心里想:等不怕,方向搞错了才要命。 16 | 17 | 说上面这段插曲的目的是想告诫大家,如果你有比较明确的方向,比如“我以后一定要做C++/Java方向的开发”,那么一定要强调出来。如果像阿里这样每个面试官都有个方向牌那很容易搞定,如果没有则可以在面试一开始的自我介绍或找其它机会说出来让面试官知道,可能有人认为语言不重要,关键是算法、数据结构、操作系统云云……是的,很多面试官都跟我说过:在以后的工作过程中,语言不重要,重要的是你以后做的东西是不是你感兴趣的,但是我认为**语言在面试过程中是有非常大的关系的,如果你是C++方向,那么面试官可能会问你一些虚函数机制、Linux下的内存分配策略、内存管理、常用系统调用等这方面的知识;如果你主攻Java,可能会问集合类区别、可研究过jdk源码、数据库等方面的知识。** 18 | 19 | 因此**面试的第一步就是让面试官明确知道你主攻的语言方向**(可能也有较好的面试官会在提问之前首先问你懂Java还是C++),如果你两个方向都非常懂并且没有比较偏爱的方向,那就无所谓了。 20 | 21 | --- 22 | 23 | ### 一面:技术面(大概40 minutes) 24 | 25 | 半个小时没到,终于给我安排了个Java方向的面试官,这次交流非常愉快。下面的“面”代表面试官。 26 | 27 | #### 第一阶段:自我介绍 28 | 29 | **面**: 请简单自我介绍下。 30 | **我**: 我是XX大学计算机专业的一名XX,我研究生期间的方向是XX,……(方向简单描述)。12年暑期在XX公司实习了4个月,做的是XX(在一所不知名的本地小公司实习过)……(其它重要项目的简述)。另外,自己是名开源积极分子,[有自己的Github](https://github.com/lanxuezaipiao/),而且今年暑期参加了CSDN举办的开源夏令营活动,做的是…… 31 | 32 | **阶段总结**:上面只是我自己当时的一个简单自我介绍,经验不足讲的比较乱,而且忘了讲自己十分热衷技术,平时喜欢写技术博客等事情(有些情况下可以加分呢)。建议大家都定制好自己的版本,讲出自己的亮点。 33 | 34 | #### 第二阶段:介绍研究生期间的论文项目,针对介绍提出几个相关的技术问题 35 | 36 | **面**:好,我看下简历。(然后对着我的简历看了十几秒,指着我的第一个项目)这是你刚说的研究生的论文项目吧(我嗯),那你把这个项目详细说下。 37 | **我**:我**从项目的选题(为啥要做这个方向)、项目采用的技术、新颖的地方、最终达到的效果(由于我做的是某个算法的性能提高,那么我就会讲速度提高了多少?空间压缩了多少?)这几个方面详细介绍了自己的项目。** 38 | 39 | 下面就是针对我的叙述具体问了几个技术相关点,这没什么好说的,因为每个人做的项目不一样,问的东西也不一样。 40 | 41 | **阶段总结**:其实要求讲的这个项目是用C++写的而不是Java,不过没关系,对于项目而言,语言就不是很重要了,关键是项目的架构、所采用的技术、能达到什么样的效果。面试官选的项目一般要么是简历中项目经验的第一个、要么是有他感兴趣的、要么项目做的时间比较长的,因此建议在写简历时,把你认为最有把握的项目放在第一位(而不是传说中的要按时间倒序来写项目经验),没太大把握的不要写(被抽问到就惨了)。只要你真真正正的吃透了被抽到的项目,那么这个项目提问阶段是完全easy的。 42 | 43 | #### 第三阶段:Java方向的知识,包括JVM原理、垃圾回收机制等 44 | 45 | **面**:你Java学的怎么样? 46 | 47 | **我**:还可以,有研究过部分JDK源码,比如常用的集合类如HashMap/Hashtable、ArrayList/LinkedList、Vector等,还有Java5之后的并发包JUC如concurrentHashMap、Executor框架、CopyOnWrite容器等。自己很欣赏Java巧妙的垃圾回收机制,看过周志明的《深入理解Java虚拟机》,因此对JVM相关的知识有所掌握…… 48 | 49 | **面**: 嗯,学的挺深的,那你把JVM的结构和类加载原理说下。 50 | 51 | **我**:马上拿起桌上的笔和纸,把虚拟机运行时包含的几个数据区和执行引擎画了下,包括方法区、虚拟机栈、本地方法栈、堆和程序计数器,然后介绍每个区域有什么作用,最后讲ClassLoader的类加载机制,还顺便说了下双亲委派机制。 52 | 53 | **面**:(面试官点头表示满意)你刚刚说Java的GC机制很巧妙,那么它的巧妙之处在哪里? 54 | 55 | **我**:我从两个方面说下自己的理解:一是Java的内存分配原理与C/C++不同,C/C++每次采用malloc或new申请内存时都要进行brk和mmap等系统调用,而系统调用发生在内核空间,每次都要中断进行切换,这需要一定的开销,而Java虚拟机是先一次性分配一块较大的空间,然后每次new时都在该空间上进行分配和释放,减少了系统调用的次数,节省了一定的开销,这有点类似于内存池的概念;二是有了这块空间过后,如何进行分配和回收就跟GC机制有关了,然后我详细介绍了GC原理、画图表示年轻代(Eden区和Survival区)、年老代、比例分配及为啥要这样分代回收(我认为巧妙就在于这里),有了GC基本结构后,我又详述了下GC是具体如何进行内存分配和垃圾回收的。 56 | 57 | **面**:(面试官一直点头表示对我回答的赞同)嗯,看来你对这块的确掌握了,对了,你说你参加的CSDN开源夏令营项目是阿里的是吧(我点头),这个夏令营是什么情况? 58 | 59 | **我**:我简单介绍了CSDN举办此次夏令营的目的,顺便说道此次夏令营活动当初有2000多人报名参加,最终只筛选出60多名,自己凭着开题报告和对开源的热爱赢得了导师的青睐得以入选。 60 | 61 | **面**:你导师是谁? 62 | 63 | **我**:淘宝的XX。 64 | 65 | **面**:哦,他啊,我认识呢,他是……(后面就简单闲聊了几句,该阶段结束,面试官让等会儿准备二面) 66 | 67 | **阶段总结**:上面的对话有人看了过后可能会说:好简单啊,问的题目都是你会的,当然能过啦。是的,其实这是有技巧在里面的,就是要想办法“先下手为强”,啥意思?即让自己成为主动摊牌者而不是被动回答者,找机会跟面试官说自己熟练掌握了哪些方面的知识、自己喜欢专研什么等等,就像上面我所做的,一开始摊牌说明自己掌握的知识处在哪些地方,引导面试官去问你想让他问的知识点,这样达到双赢的目的(你爽了,面试官也轻松了,因为他不用老是猜你可能知道哪些东西然后试探性的问你这个会吗那个了解过吗)。 68 | 69 | ### 二面:技术面 + HR面(大概1 hour) 70 | 71 | 一面很轻松的就过了,但是二面就相对而言有些吃力,问的完全是项目相关,而且不是我最熟的研究生期间的论文项目,而是另外两个项目,由于复习不到位,某些地方回答的不完善。 72 | 73 | #### 第一阶段:自我介绍,同上 74 | 75 | #### 第二阶段:介绍面试官感兴趣的两个项目,一个与推荐系统相关,另一个与Java web相关 76 | 77 | **面**: 介绍下你简历上的这个电影个性化推荐引擎,使用的是哪种推荐算法? 78 | 79 | **我**: 改进的基于用户的协同过滤推荐算法。 80 | 81 | **面**: 那好,那你从项目的基本架构、所使用的算法原理、如何改进的、数据如何处理这几个方面介绍下你的项目吧。 82 | 83 | **我**: 我首先画了下项目的架构图,据此图详细讲了下UserCF的原理及如何使用用户的社交数据和六维理论改进传统的UserCF,并写出了改进后的算法公式。然后又说这个项目的数据多大,代码中采用什么数据结构进行处理的。 84 | 85 | **面**: (介绍原理中提到了利用用户相似性来作为推荐的一个参考,面试官追问)那用户的相似性你怎么算的? 86 | 87 | **我**: (汗,这个有个计算公式,我不太记得了,最后根据自己的理解讲了下余弦相似性的计算方式,公式没写全,面试官问公式里的根号怎么算的,我说直接用Java的库函数) 88 | 89 | **面**: 你这数据哪来的?有几类数据?数据的存储格式是什么? 90 | 91 | **我**: (该项目时间有点久了,前几天只复习了项目的整体架构和算法原理,忘了看具体的数据了,这里只能凭自己的记忆讲了下数据的存储格式,回来后发现自己讲的虽然没错但不够具体) 92 | 93 | **附**:该电影个性化推荐引擎我早已经放到了自己的Github上面,是自己在老师的指导下做的,纯算法,还比较简单有待于改进。 94 | 95 | 介绍完了这个项目,马上面试官又看中了另一个Java web相关的项目,马上追问。 96 | **面**:嗯,你这个XX系统是用ssh2框架做的,那你对这个框架熟吗? 97 | 98 | **我**:嗯,当时在公司实习时对ssh的掌握程度只是会使用级别,那时候没时间去研究框架背后的原理。后来有闲暇时间后,我就深入研究了下这几个框架的原理,还看了部分spring的源码,学到了不少知识。 99 | 100 | **面**:嗯,那你把这三个框架都介绍下。 101 | 102 | **我**:我开始按自己的理解按Hibernate、Struts、Spring的顺序开始讲,Hibernate讲到它的使用原理及与iBATIS的对比,顺便说了下现在似乎大家更倾向于使用iBATIS、myBATIS这样更加灵活的轻量级框架。struts讲了下它的作用就是“将请求与视图分开”,然后讲述从输入url到使用struts处理的控制流程(struts从tomcat那接管、action处理),然后也说struts现在似乎也不那么倾向于使用因为它有漏洞。最后重点讲了下重头戏Spring,详细讲述了它解耦的功能、AOP原理及自己有利用动态代理简单模拟实现过一个简单的AOP功能、IOC(DI)等。最后说,从web应用层面上看,Hibernate属于持久层,struts属于表示层,而Spring却贯穿所有于所有层(表示层、业务层、持久层),Spring也有自己的MVC模块、web模块及JDBC和DAO模块,只是很少使用,也就是只用一个Spring也是完全可以的。 103 | 104 | **面**:(点头表示肯定)你刚说到struts有漏洞,那么Hibernate是安全的吗?有没有可能发生xss攻击和sql注入攻击? 105 | 106 | **我**:(汗,这个问题真心没想过,对Hibernate的掌握没有Spring那么深,只能硬着头皮按自己的理解回答)这个问题没想过,不过我觉得框架没有绝对的安全,Hibernate是用来操作数据库的,hql语句里也有select、where判断,应该有可能发生sql注入攻击,xss攻击就不太清楚了。(这个回答太糟了) 107 | 108 | 面试官没说啥,一直在电脑上写着什么东西。这时候旁边的HR终于发话了。 109 | **HR**: 你本科是哪的?为什么选择考研? 110 | 111 | **我**: 开始说出我的“发家史”,从一所不知名的小二本考到了中科大,…… 112 | 113 | **HR**: 那你技术上是怎么学习的? 114 | 115 | **我**: 又从本科说起,本科技术很差,到了研究生期间才真正开始技术上的修炼,……balabala 116 | 117 | **HR**: 你的职业规划是什么? 118 | 119 | **我**: ……(每个人的想法不一样) 120 | 121 | **HR**: 你最大的优势是什么? 122 | 123 | **我**: (自己吹吧,也要根据实际情况看) 124 | …… 125 | 126 | **阶段总结**:再次说明项目的重要性,第一个项目有些记忆模糊,答的有瑕疵,这里要引以为戒(一定要对项目知根知底),第二个项目感觉答的还可以,不过Hibernate安全问题没答出来,我觉得只要你其它问题答的很好,有个别问题答不出来是不会影响最终的offer的。HR面也很重要,你得说通了,需要提前考虑好常见问题的回答。 127 | 128 | #### 第三阶段:到你提问了 129 | 130 | 自由发挥阶段,可以**问问公司内部的培养计划、晋升机制、是否经常有大牛分享技术让我们学习等等……** 131 | 132 | --- 133 | 134 | ## 3. 总结 135 | (1)整个面试过程中没让写代码,没问Linux下的一些知识,也没问操作系统、计算机网络相关,我觉得可能是Java面试更倾向于从项目中问相关的技术问题,如果你没项目或项目不多,那么就可能问这些计算机基础知识了。 136 | 137 | (2)由于之前内推电面的失败,让我丧失了一些小自信,因此在这次阿里的整体面试过程中还是有些紧张,大家请引以为戒,务必在面试中保持淡定的心态,就当是和朋友在一起交流技术问题。 138 | 139 | (3)最后,希望我上面对话形式的面经能够给正在找工作或以后找工作的同学们带来一些借鉴意义,希望你们能够从中看出某些问题的答题技巧和所做的准备工作。 -------------------------------------------------------------------------------- /Skills/10道C++输出易错笔试题收集(敢进来挑战吗?).md: -------------------------------------------------------------------------------- 1 | 下面这些题目都是我之前准备笔试面试过程中积累的,大部分都是知名公司的笔试题,C++基础薄弱的很容易栽进去。我从中选了10道简单的题,C++初学者可以进来挑战下,C++大牛也可以作为娱乐玩下(比如下面的第6题)。为了便于大家思考,将题目与答案分开,不过无论题目本身如何,我觉得**后面的解析过程更值得学习,因为涉及很多我们学习C++过程中必知必会的小知识点 。** 2 | 3 | ### 第一部分:题目 4 | 1. 如下函数,在32 bit系统foo(2^31-3)的值是:() 5 | ```cpp 6 | int foo(int x) 7 | { 8 | return x&-x; 9 | } 10 | ``` 11 | A:0 B: 1 C: 2 D: 4 12 | 13 | 2. 运算符优先级 14 | unsigned char i=0x80; 15 | printf("0x%x\n", ~i>>3+1); 16 | 输出什么? 17 | 18 | 3. 静态对象是否调用构造函数? 19 | ```cpp 20 | #include 21 | using namespace std; 22 | 23 | class A 24 | { 25 | public: 26 | A() { cout << "A's Constructor Called " << endl; } 27 | }; 28 | 29 | class B 30 | { 31 | static A a; 32 | public: 33 | B() { cout << "B's Constructor Called " << endl; } 34 | }; 35 | 36 | int main() 37 | { 38 | B b; 39 | return 0; 40 | } 41 | ``` 42 | 43 | 4. union问题 44 | ```cpp 45 | #include 46 | 47 | union 48 | { 49 | int i; 50 | char x[2]; 51 | }a; 52 | int main() 53 | { 54 | a.x[0] = 10; 55 | a.x[1] = 1; 56 | printf("%d",a.i); 57 | return 0; 58 | } 59 | ``` 60 | 61 | 5. 下面代码会报错吗?为什么? 62 | ```cpp 63 | class A { 64 | public: 65 | int m; 66 | void print() { cout << "A\n"; } 67 | }; 68 | A *pa = 0; 69 | pa->print(); 70 | ``` 71 | 72 | 6. 下面代码的输出是什么?(非常考基础水平的一道题) 73 | ```cpp 74 | char *c[] = {"ENTER","NEW","POINT","FIRST"}; 75 | char **cp[] = { c + 3 , c + 2 , c + 1 , c}; 76 | char ***cpp = cp; 77 | int main(void) 78 | { 79 | printf("%s",**++cpp); 80 | printf("%s",*--*++cpp+3); 81 | printf("%s",*cpp[-2]+3); 82 | printf("%s\n",cpp[-1][-1]+1); 83 | 84 | return 0; 85 | } 86 | ``` 87 | 88 | 7. 结构体 89 | ```cpp 90 | #include 91 | struct data 92 | { 93 | int a; 94 | unsigned short b; 95 | }; 96 | int main(void) 97 | { 98 | data mData; 99 | mData.b = 0x0102; 100 | char *pData = (char *)&mData; 101 | printf("%d %d", sizeof(pData), (int)(*(pData + 4))); 102 | return 0; 103 | } 104 | ``` 105 | 106 | 8. 改变string变量的值? 107 | ```cpp 108 | #include 109 | #include 110 | using namespace std; 111 | void chg_str(string str) { 112 | str = "ichgit"; 113 | } 114 | int main() { 115 | string s = "sarrr"; 116 | chg_str(s); 117 | 118 | printf("%s\n", s.c_str()); 119 | cout << s << endl; 120 | return 0; 121 | } 122 | ``` 123 | 124 | 9. 静态变量的输出 125 | ```cpp 126 | #include 127 | int sum(int a) { 128 | int c = 0; 129 | static int b = 3; // 只执行一次 130 | c++; 131 | b += 2; 132 | return (a + b + c); 133 | } 134 | int main() { 135 | int i; 136 | int a = 2; 137 | for(i = 0; i < 5; ++i) { 138 | printf("%d\n", sum(a)); 139 | } 140 | return 0; 141 | } 142 | ``` 143 | 144 | 10. 返回值加const修饰的必要性 145 | 你觉得下面两种写法有区别吗? 146 | ```cpp 147 | int GetInt(void) 148 | const int GetInt(void) 149 | ``` 150 | 如果是下面的呢?其中A 为用户自定义的数据类型。 151 | ```cpp 152 | A GetA(void) 153 | const A GetA(void) 154 | ``` 155 |

156 |

157 | 158 | 159 | --- 160 | ### 第二部分:答案详细解析 161 | 1. 如下函数,在32 bit系统foo(2^31-3)的值是: 162 | ```cpp 163 | int foo(int x) 164 | { 165 | return x&-x; 166 | } 167 | ``` 168 | A:0 B: 1 C: 2 D: 4 169 | 答案:C 170 | 解释:我只想说注意运算符优先级,注意^是异或而不是幂次方。 171 | 172 | 2. 运算符优先级 173 | unsigned char i=0x80; 174 | printf("0x%x\n", ~i>>3+1);输出什么? 175 | 输出:0xfffffff7(提示:+的优先级优于>>) 176 | 如果将unsigned去掉,则输出0x7。 177 | 178 | 3. 静态对象是否调用构造函数? 179 | ```cpp 180 | #include 181 | using namespace std; 182 | 183 | class A 184 | { 185 | public: 186 | A() { cout << "A's Constructor Called " << endl; } 187 | }; 188 | 189 | class B 190 | { 191 | static A a; 192 | public: 193 | B() { cout << "B's Constructor Called " << endl; } 194 | }; 195 | 196 | int main() 197 | { 198 | B b; 199 | return 0; 200 | } 201 | ``` 202 | 203 | 输出: 204 | > B's Constructor Called 205 | 206 | 解释:上面的程序只是调用了B的构造函数,没有调用A的构造函数**。因为静态成员变量只是在类中声明,没有定义。静态成员变量必须在类外使用作用域标识符显式定义。** 207 | 如果我们没有显式定义静态成员变量a,就试图访问它,编译会出错,比如下面的程序编译出错: 208 | ```cpp 209 | #include 210 | using namespace std; 211 | 212 | class A 213 | { 214 | int x; 215 | public: 216 | A() { cout << "A's constructor called " << endl; } 217 | }; 218 | 219 | class B 220 | { 221 | static A a; 222 | public: 223 | B() { cout << "B's constructor called " << endl; } 224 | static A getA() { return a; } 225 | }; 226 | 227 | int main() 228 | { 229 | B b; 230 | A a = b.getA(); 231 | return 0; 232 | } 233 | ``` 234 | 输出: 235 | >Compiler Error: undefined reference to `B::a 236 | 237 | 如果我们加上a的定义,那么上面的程序可以正常运行, 238 | **注意:如果A是个空类,没有数据成员x,则就算B中的a未定义也还是能运行成功的,即可以访问A。** 239 | ```cpp 240 | #include 241 | using namespace std; 242 | 243 | class A 244 | { 245 | int x; 246 | public: 247 | A() { cout << "A's constructor called " << endl; } 248 | }; 249 | 250 | class B 251 | { 252 | static A a; 253 | public: 254 | B() { cout << "B's constructor called " << endl; } 255 | static A getA() { return a; } 256 | }; 257 | 258 | A B::a; // definition of a 259 | 260 | int main() 261 | { 262 | B b1, b2, b3; 263 | A a = b1.getA(); 264 | 265 | return 0; 266 | } 267 | ``` 268 | 输出: 269 | >A's constructor called 270 | B's constructor called 271 | B's constructor called 272 | B's constructor called 273 | 274 | 上面的程序调用B的构造函数3次,但是只调用A的构造函数一次,**因为静态成员变量被所有对象共享**,这也是它被称为类变量的原因。同时,静态成员变量也可以通过类名直接访问,比如下面的程序没有通过任何类对象访问,只是通过类访问a。 275 | ```cpp 276 | int main() 277 | { 278 | // static member 'a' is accessed without any object of B 279 | A a = B::getA(); 280 | 281 | return 0; 282 | } 283 | ``` 284 | 输出: 285 | >A's constructor called 286 | 287 | 4. union问题 288 | ```cpp 289 | #include 290 | 291 | union 292 | { 293 | int i; 294 | char x[2]; 295 | }a; 296 | int main() 297 | { 298 | a.x[0] = 10; 299 | a.x[1] = 1; 300 | printf("%d",a.i); 301 | return 0; 302 | } 303 | ``` 304 | 输出:266,自己画个内存结构图就知道了,注意union的存放顺序是所有成员都从低地址开始存放。Union的大小为其内部所有变量的最大值,并且按照类型最大值的整数倍进行内存对齐。 305 | 306 | 5. 下面代码会报错吗?为什么? 307 | ```cpp 308 | class A { 309 | public: 310 | int m; 311 | void print() { cout << "A\n"; } 312 | }; 313 | A *pa = 0; 314 | pa->print(); 315 | ``` 316 | 答案:正常输出。**上面的代码可以这样理解(这非常重要):** 317 | ```cpp 318 | void print(A *this) { cout << "A\n"; } 319 | A *pa = 0; 320 | print_A(); 321 | ``` 322 | 也就是:**并不是类没有初始化就不能调用类的成员函数,如果成员函数只是简单的打印个东西,没有调用类成员啥的就不会报段错误。** 323 | 324 | 6. 下面代码的输出是什么?(非常考基础水平的一道题) 325 | ```cpp 326 | char *c[] = {"ENTER","NEW","POINT","FIRST"}; 327 | char **cp[] = { c + 3 , c + 2 , c + 1 , c}; 328 | char ***cpp = cp; 329 | int main(void) 330 | { 331 | printf("%s",**++cpp); 332 | printf("%s",*--*++cpp+3); 333 | printf("%s",*cpp[-2]+3); 334 | printf("%s\n",cpp[-1][-1]+1); 335 | 336 | return 0; 337 | } 338 | ``` 339 | 解答: 340 | **c是一个指针数组,每个数组元素都是char*类型的指针**,值分别是那些字符串(的首地址): 341 | >c[0] = "ENTER" 342 | c[1] = "NEW" 343 | c[2] = "POINT" 344 | c[3] = "FIRST" 345 | 346 | 而[]和\*是本质一样的运算,即`c[i]=*(c+i)`。 347 | 348 | **c和c+i都是char \*[]类型,它可以退化成char \*\*类型**,再看cp,它正好是一个char \*\*的数组,来看它的值: 349 | >cp[0] = c + 3 350 | cp[1] = c + 2 351 | cp[2] = c + 1 352 | cp[3] = c 353 | 354 | 引用后就有:`cp[0][0]=*(c + 3)=c[3]="FIRST"`,以此类推。 355 | 356 | **cp是char \*\*[]类型,它可以退化成char \*\*\*类型**,看最后的cpp,它正是char \*\*\*类型,它是一个指针变量,和上面两个不同,上面两个是数组。 357 | 358 | 这样分析过后,下面的解析就一目了然了: 359 | - `printf("%s",**++cpp); ` 360 | ++cpp的值是cp+1,引用一次后是cp[1]再引用是*cp[1]=c[2]="POINT",第一句的输出 361 | - `printf("%s",*--*++cpp+3); ` 362 | 再++cpp的值是cp+2,引用一次是cp[2]=c+1,再对这进行--,减后是c再引用是c[0]="ENTER"再+3,字符串指针指到"ER",输出是"ER" 363 | - `printf("%s",*cpp[-2]+3); ` 364 | 这时cpp的值是cp+2,cpp[-2]=\*(cpp-2)=\*(cp+2-2)=cp[0]=c+3,再引用是c[3]="FIRST",+3 字符串指针指到"ST",输出是"ST" 365 | - `printf("%s\n",cpp[-1][-1]+1); ` 366 | cpp还是cp+2,cpp[-1]=\*(cpp-1)=\*(cp+2-1)=cp[1]=c+2,再[-1]得*(c+2-1)=c[1]="NEW",+1字符串指针指到"EW",输出是"EW"。 367 | 368 | 7. 结构体 369 | ```cpp 370 | #include 371 | struct data 372 | { 373 | int a; 374 | unsigned short b; 375 | }; 376 | int main(void) 377 | { 378 | data mData; 379 | mData.b = 0x0102; 380 | char *pData = (char *)&mData; 381 | printf("%d %d", sizeof(pData), (int)(*(pData + 4))); 382 | return 0; 383 | } 384 | ``` 385 | 输出:4 2 386 | 说明:一般变量都是从高到低分配内存地址,但对于结构体来说,**结构体的成员在内存中顺序存放,所占内存地址依次增高,第一个成员处于低地址处,最后一个成员处于最高地址处**,但结构体成员的内存分配不一定是连续的,编译器会对其成员变量依据前面介绍的 “对齐”原则进行处理。 387 | ![结构体内存分布图](http://upload-images.jianshu.io/upload_images/46178-167e61532176a47d.jpg) 388 | 389 | **补充知识点:** 390 | >除了栈以外,**堆、只读数据区、全局变量地址增长方向都是从低到高的。** 391 | 392 | 8. 改变string变量的值? 393 | ```cpp 394 | #include 395 | #include 396 | using namespace std; 397 | void chg_str(string str) { 398 | str = "ichgit"; 399 | } 400 | int main() { 401 | string s = "sarrr"; 402 | chg_str(s); 403 | 404 | printf("%s\n", s.c_str()); 405 | cout << s << endl; 406 | return 0; 407 | } 408 | ``` 409 | 输出:仍为“sarrr”。 410 | 解释:string是**传值参数,不能修改其值。**要想改变string变量的值,可以改为传地址方式: 411 | ```cpp 412 | #include 413 | #include 414 | using namespace std; 415 | void chg_str(string *str) { 416 | *str = "ichgit"; 417 | } 418 | int main() { 419 | string s = "sarrr"; 420 | chg_str(&s); 421 | 422 | printf("%s\n", s.c_str()); 423 | cout << s << endl; 424 | return 0; 425 | } 426 | ``` 427 | 428 | 9. 静态变量的输出 429 | ```cpp 430 | #include 431 | int sum(int a) { 432 | int c = 0; 433 | static int b = 3; // 只执行一次 434 | c++; 435 | b += 2; 436 | return (a + b + c); 437 | } 438 | int main() { 439 | int i; 440 | int a = 2; 441 | for(i = 0; i < 5; ++i) { 442 | printf("%d\n", sum(a)); 443 | } 444 | return 0; 445 | } 446 | ``` 447 | 输出:8 10 12 14 16 448 | 解释:存储在静态数据区的变量会在程序刚开始运行时就完成初始化,也是唯一的一次初始化,**此后该初始化不再执行,相当于一次执行后就作废**,静态局部变量保存了前次被调用后留下的值。 449 | 450 | 10. 返回值加const修饰的必要性 451 | 你觉得下面两种写法有区别吗? 452 | ```cpp 453 | int GetInt(void) 454 | const int GetInt(void) 455 | ``` 456 | 如果是下面的呢?其中A 为用户自定义的数据类型。 457 | ```cpp 458 | A GetA(void) 459 | const A GetA(void) 460 | ``` 461 | 答案:没有任何区别。 462 | 解释:如果函数返回值采用“值传递方式”,由于函数会把返回值复制到外部临时的存储单元中,加const 修饰没有任何价值。所以,对于值传递来说,加const没有太多意义。 463 | 所以: 464 | - 不要把函数int GetInt(void) 写成const int GetInt(void)。 465 | - 不要把函数A GetA(void) 写成const A GetA(void)。 466 | 467 | **在编程中要尽可能多的使用const(比如函数参数采用const&修饰),这样可以获得编译器的帮助,以便写出健壮性的代码**。 -------------------------------------------------------------------------------- /Baidu/百度2014研发类校园招聘笔试题解答.md: -------------------------------------------------------------------------------- 1 | 先总体说下题型,共有3道简答题,3道算法编程题和1道系统设计题,题目有难有易,限时两小时完成。 2 | 3 | **一、简答题** 4 | 5 | 1. 动态链接库和静态链接库的优缺点 6 | 7 | 2. 轮询任务调度和可抢占式调度有什么区别? 8 | 9 | 3. 列出数据库中常用的锁及其应用场景 10 | 11 | **二、算法设计题** 12 | 13 | 1. 给定N是一个正整数,求比N大的最小“不重复数”,这里的不重复是指没有两个相等的相邻位,如1102中的11是相等的两个相邻位故不是不重复数,而12301是不重复数。 14 | 15 | 2. 设N是一个大整数,求长度为N的字符串的最长回文子串。 16 | 17 | 3. 坐标轴上从左到右依次的点为a[0]、a[1]、a[2]……a[n-1],设一根木棒的长度为L,求L最多能覆盖坐标轴的几个点? 18 | 19 | **三、系统设计题** 20 | 21 | 1. 在现代系统的设计过程中,为了减轻请求的压力,通常采用缓存技术,为了进一步提升缓存的命中率,同常采用分布是缓存方案。调度模块针对不同内容的用户请求分配给不同的缓存服务器向用户提供服务。请给出一个分布式缓存方案,满足如下要求: 22 | 23 | 1) 单台缓存服务器故障,整个分布式缓存集群,可以继续提供服务。 24 | 25 | 2)通过一定得分配策略,可以保证充分利用每个缓存服务的存储空间,及负载均衡。当部分服务器故障或系统扩容时,改分配策略可以保证较小的缓存文件重分配开销。 26 | 27 | 3)当不同缓存服务器的存储空间存在差异时,分配策略可以满足比例分配。 28 | 29 | 下面给出我自己的一些解答,不保证100%正确,欢迎批评指正。 30 | 31 | ### 一、简答题 32 | 33 | **1. 动态链接库和静态链接库的优缺点** 34 | 解答:(1) 动态链接库(Dynamic Linked Library): Windows为应用程序提供了丰富的函数调用,这些函数调用都包含在动态链接库中。 其中有3个最重要的DLL,Kernel32.dll、 User32.dll和GDI32.dll。 有两种使用方式:一种是静态加载,即在应用程序启动时被加载;一种是动态加载,即是该动态链接库在被使用时才被应用程序加载。 35 | >优点如下: 36 | a. 共享:多个应用程序可以使用同一个动态库,启动多个应用程序的时候,只需要将动态库加载到内存一次即可; 37 | b. 开发模块好:要求设计者对功能划分的比较好。 38 | 39 | >缺点是不能解决引用计数等问题。 40 | 41 | (2)静态库(Static Library): 函数和数据被编译进一个二进制文件(通常扩展名为.LIB)。 在使用静态库的情况下,在编译链接可执行文件时,链接器从库中复制这些函数和数据并把它们和应用程序的其它模块组合起来创建最终的可执行文件(.EXE文件)。 静态链接库作为代码的一部分,在编译时被链接。 42 | >优缺点如下: 43 | 代码的装载速度快,因为编译时它只会把你需要的那部分链接进去,应用程序相对比较大。但是如果多个应用程序使用的话,会被装载多次,浪费内存。 44 | 45 | **2. 轮询任务调度和可抢占式调度有什么区别?** 46 | 47 | 解答:(1)轮询调度的原理是每一次把来自用户的请求轮流分配给内部中的服务器,从1开始,直到N(内部服务器个数),然后重新开始循环。 只有在当前任务主动放弃CPU控制权的情况下(比如任务挂起),才允许其他任务(包括高优先级的任务)控制CPU。其优点是其简洁性,它无需记录当前所有连接的状态,所以它是一种无状态调度。但不利于后面的请求及时得到响应。 48 | 49 | (2)抢占式调度允许高优先级的任务打断当前执行的任务,抢占CPU的控制权。这有利于后面的高优先级的任务也能及时得到响应。但实现相对较复杂且可能出现低优先级的任务长期得不到调度。 50 | 51 | **3. 列出数据库中常用的锁及其应用场景** 52 | 53 | 解答:数据库中的锁是网络数据库中的一个非常重要的概念,它主要用于多用户环境下保证数据库完整性和一致性。各种大型数据库所采用的锁的基本理论是一致的,但在具体实现上各有差别。目前,大多数数据库管理系统都或多或少具有自我调节、自我管理的功能,因此很多用户实际上不 清楚锁的理论和所用数据库中锁的具体实现。在数据库中加锁时,除了可以对不同的资源加锁,还可以使用不同程度的加锁方式,即锁有多种模式,SQL Server中锁模式包括: 54 | 55 | 1)共享锁 56 | SQL Server中,共享锁用于所有的只读数据操作。共享锁是非独占的,允许多个并发事务读取其锁定的资源。默认情况下,数据被读取后,SQL Server立即释放共享锁。例如,执行查询“SELECT \* FROM my_table”时,首先锁定第一页,读取之后,释放对第一页的锁定,然后锁定第二页。这样,就允许在读操作过程中,修改未被锁定的第一页。但是,事务 隔离级别连接选项设置和SELECT语句中的锁定设置都可以改变SQL Server的这种默认设置。例如,“ SELECT * FROM my_table HOLDLOCK”就要求在整个查询过程中,保持对表的锁定,直到查询完成才释放锁定。 57 | 58 | 2)修改锁 59 | 修 改锁在修改操作的初始化阶段用来锁定可能要被修改的资源,这样可以避免使用共享锁造成的死锁现象。因为使用共享锁时,修改数据的操作分为两步,首先获得一个共享锁,读取数据,然后将共享锁升级为独占锁,然后再执行修改操作。这样如果同时有两个或多个事务同时对一个事务申请了共享锁,在修改数据的时候,这些 事务都要将共享锁升级为独占锁。这时,这些事务都不会释放共享锁而是一直等待对方释放,这样就造成了死锁。如果一个数据在修改前直接申请修改锁,在数据修 改的时候再升级为独占锁,就可以避免死锁。修改锁与共享锁是兼容的,也就是说一个资源用共享锁锁定后,允许再用修改锁锁定。 60 | 61 | 3)独占锁 62 | 独占锁是为修改数据而保留的。它所锁定的资源,其他事务不能读取也不能修改。独占锁不能和其他锁兼容。 63 | 64 | 4)结构锁 65 | 结构锁分为结构修改锁(Sch-M)和结构稳定锁(Sch-S)。执行表定义语言操作时,SQL Server采用Sch-M锁,编译查询时,SQL Server采用Sch-S锁。 66 | 67 | 5)意向锁 68 | 意 向锁说明SQL Server有在资源的低层获得共享锁或独占锁的意向。例如,表级的共享意向锁说明事务意图将独占锁释放到表中的页或者行。意向锁又可以分为共享意向锁、 独占意向锁和共享式独占意向锁。共享意向锁说明事务意图在共享意向锁所锁定的低层资源上放置共享锁来读取数据。独占意向锁说明事务意图在共享意向锁所锁定 的低层资源上放置独占锁来修改数据。共享式独占锁说明事务允许其他事务使用共享锁来读取顶层资源,并意图在该资源低层上放置独占锁。 69 | 70 | 6)批量修改锁 71 | 批量复制数据时使用批量修改锁。可以通过表的TabLock提示或者使用系统存储过程sp_tableoption的“table lock on bulk load”选项设定批量修改锁。 72 | 73 | ### 二、算法设计题 74 | 75 | **1. 给定N是一个正整数,求比N大的最小“不重复数”,这里的不重复是指没有两个相等的相邻位,如1102中的11是相等的两个相邻位故不是不重复数,而12301是不重复数。** 76 | 77 | **算法思想**:当然最直接的方法是采用暴力法,从N+1开始逐步加1判断是否是不重复数,是就退出循环输出,这种方法一般是不可取的,例如N=11000000,你要一个个的加1要加到12010101,一共循环百万次,每次都要重复判断是否是不重复数,效率极其低下,因此是不可取的。这里我采用的方法是:从N+1的最高位往右开始判断与其次高位是否相等,如果发现相等的(即为重复数)则将次高位加1,注意这里可能进位,如8921—>9021,后面的直接置为010101...形式,如1121—>1201,此时便完成“不重复数”的初步构造,但此时的“不重复数”不一定是真正的不重复的数,因为可能进位后的次高位变为0或进位后变成00,如9921—>10001,此时需要再次循环判断重新构造直至满足条件即可,这种方法循环的次数比较少,可以接受。 78 | 79 | Source Code: 80 | ```c++ 81 | // 求比指定数大且最小的“不重复数” 82 | 83 | #include 84 | 85 | void minNotRep(int n) 86 | { 87 | // 需要多次判断 88 | while(1) 89 | { 90 | int a[20], len = 0, i, b = 0; 91 | // flag为true表示是“重复数”,为false表示表示是“不重复数” 92 | bool flag = false; 93 | 94 | // 将n的各位上数字存到数组a中 95 | while(n) 96 | { 97 | a[len++] = n % 10; 98 | n = n / 10; 99 | } 100 | 101 | // 从高位开始遍历是否有重复位 102 | for(i = len - 1; i > 0; i--) 103 | { 104 | // 有重复位则次高位加1(最高位有可能进位但这里不需要额外处理) 105 | if(a[i] == a[i - 1] && !flag) 106 | { 107 | a[i - 1]++; 108 | flag = true; 109 | } 110 | else if(flag) 111 | { 112 | // 将重复位后面的位置为0101...形式 113 | a[i - 1] = b; 114 | b = (b == 0) ? 1 : 0; 115 | } 116 | } 117 | 118 | // 重组各位数字为n,如果是“不重复数”则输出退出否则继续判断 119 | for(i = len - 1; i >= 0; i--) 120 | { 121 | n = n * 10 + a[i]; 122 | } 123 | 124 | if(!flag) 125 | { 126 | printf("%d\n", n); 127 | break; 128 | } 129 | } 130 | } 131 | 132 | int main() 133 | { 134 | int N; 135 | 136 | while(scanf("%d", &N)) 137 | { 138 | minNotRep(N + 1); 139 | } 140 | 141 | return 0; 142 | } 143 | ``` 144 | 145 | ![运行结果](http://upload-images.jianshu.io/upload_images/46178-cab291c5db2b3b4d.png) 146 | 147 | 148 | **2. 设N是一个大整数,求长度为N的字符串的最长回文子串。** 149 | 150 | **算法1**:第一个方法当然是暴力法,外面的两层循环找到所有子串,第三层循环判断子串是否是回文。方法的时间复杂度为O(n^3),空间复杂度为O(1)。 151 | 152 | **算法2**:采用动态规划法判断子串是否是回文。开辟一个P[i][j]用来表示str[i..j]是否为回文,P[i][j]的状态转移方程如下: 153 | >1. 当i==j时,P[i][j]=true 154 | 2. 当i+1==j时,P[i][j]=str[i]==str[j] 155 | 3. 其他,P[i][j]=P[i+1][j-1]&&(str[i]==str[j]) 156 | 157 | 那么P[i][j]中j-i+1最大的且值为true的就是最长回文子串。这样,这个方法的时间复杂度为O(n^2),空间复杂度为O(n^2)。比暴力法有很大的改进。 158 | 159 | Source Code: 160 | ```c++ 161 | #include 162 | #include 163 | #include 164 | 165 | int longestPalSubstr(char *str) 166 | { 167 | int n = strlen(str); 168 | int i, j, len, maxlen = 0, maxi = 0, maxj = 0; 169 | bool **P = (bool**)malloc(sizeof(bool) * n); 170 | 171 | for(i = 0; i < n; i++) 172 | { 173 | P[i] = (bool*)malloc(sizeof(bool) * n); 174 | } 175 | 176 | // initialize P[i][i] 177 | for(i = 0; i < n; i++) 178 | { 179 | P[i][i] = true; 180 | } 181 | 182 | // compute P[n][n] by length 183 | for(len = 2; len <= n; len++) 184 | { 185 | for(i = 0; i < n - len + 1; i++) 186 | { 187 | j = i + len - 1; 188 | if(len == 2) 189 | { 190 | P[i][j] = (str[i] == str[j]); 191 | } 192 | else 193 | { 194 | P[i][j] = ((str[i] == str[j]) && P[i + 1][j - 1]); 195 | } 196 | } 197 | } 198 | 199 | // int k; 200 | for(i = 0; i < n; i++) 201 | { 202 | for(j = i; j < n; j++) 203 | { 204 | // printf("%d ", P[i][j]); 205 | if(P[i][j] && maxlen < (j - i + 1)) 206 | { 207 | maxlen = j - i + 1; 208 | maxi = i; 209 | maxj = j; 210 | } 211 | } 212 | // printf("\n"); 213 | // for(k = 0; k <= i; k++) 214 | // printf(" "); 215 | } 216 | 217 | printf("The longest palin substr is "); 218 | for(i = maxi; i <= maxj; i++) 219 | { 220 | printf("%c", str[i]); 221 | } 222 | printf(", maxlen is %d\n\n", maxlen); 223 | 224 | return maxlen; 225 | } 226 | 227 | int main() 228 | { 229 | char str[100]; 230 | 231 | while(1) 232 | { 233 | gets(str); 234 | if(strlen(str) == 0) break; 235 | longestPalSubstr(str); 236 | } 237 | 238 | return 0; 239 | } 240 | ``` 241 | 242 | 243 | ![运行结果](http://upload-images.jianshu.io/upload_images/46178-178e4a2eb03f5ca5.png) 244 | 245 | 246 | **算法3**:第三个方法,可以从上面那个方法的状态转移方程获得启发,对于每一个回文子串可以先确定一个中心,然后向两边扩展,这样可以在时间复杂度O(n^2),空间复杂度O(1)的情况下完成,需要注意的是,长度为奇数和偶数的中心的情况是不同的。 247 | 248 | Source Code: 249 | ```c++ 250 | #include 251 | #include 252 | #include 253 | 254 | int longestPalSubstr(char *str) 255 | { 256 | int len = strlen(str); 257 | int i, maxLen = 1, start = 0; 258 | int low, high; 259 | 260 | // 将每个字符作为中心向两边扩展判断 261 | for(i = 1; i < len; i++) 262 | { 263 | // 处理长度为偶数的情况 264 | low = i - 1; 265 | high = i; 266 | while(low >= 0 && high < len && str[low] == str[high]) 267 | { 268 | if(maxLen < high - low + 1) 269 | { 270 | start = low; 271 | maxLen = high - low + 1; 272 | } 273 | low--; 274 | high++; 275 | } 276 | 277 | // 处理长度为奇数的情况 278 | low = i - 1; 279 | high = i + 1; 280 | while(low >= 0 && high < len && str[low] == str[high]) 281 | { 282 | if(maxLen < high - low + 1) 283 | { 284 | start = low; 285 | maxLen = high - low + 1; 286 | } 287 | low--; 288 | high++; 289 | } 290 | } 291 | 292 | printf("The longest palin substr is "); 293 | for(i = start; i < start + maxLen; i++) 294 | { 295 | printf("%c", str[i]); 296 | } 297 | printf(", maxlen is %d\n\n", maxLen); 298 | 299 | return maxLen; 300 | } 301 | 302 | int main() 303 | { 304 | char str[100]; 305 | 306 | while(1) 307 | { 308 | gets(str); 309 | if(strlen(str) == 0) break; 310 | longestPalSubstr(str); 311 | } 312 | 313 | return 0; 314 | } 315 | ``` 316 | 317 | **算法4**:第四个方法采用后缀数组,将最长回文子串的问题转化为最长公共前缀的问题。具体的做法就是:将整个字符串翻转之后,拼接到原字符串后,注意用特殊字 符分开,这样问题就变成了新的字符串的某两个后缀的最长公共前缀的问题了。这个方法比较强大,很多字符串的问题都能够巧妙的解决。不过实现起来也相对比较:难,好的实现和差的实现时间复杂度相差很大。由于对后缀数组不是很清楚,未写代码,等学习了后缀数组再过来补。 318 | 319 | **算法5**:第五个方法叫做Manacher算法,是一种线性时间的方法,非常巧妙。首先,我们在上面的方法中个,都要考虑回文长度为奇数或者偶数的情况。这个:方法,引入一个技巧,使得奇数和偶数的情况统一处理了。具体做法如下: 320 | 321 | abba转换为#a#b#b#a#,也就是在每一个字符两边都加上一个特殊字符。 322 | 323 | 然后创建一个新的P[i]表示,以第i个字符为中心的回文字串的半径。例如上面的例子,对应的P如下,设S为原始字符串: 324 | 325 | >S # a # b # b # a # 326 | P 1 2 1 2 5 2 1 2 1 327 | 328 | 通过观察上面的表,大家可以发现P[i]-1就是实际回文字串的长度。如果知道P,遍历一次就知道最长的回文子串。可以该如何计算P呢?这是这个算法最核心的部分。 329 | 330 | 下面的讨论基本转自博客:http://www.felix021.com/blog/read.php?2040 该博客中对Manacher算法介绍得也非常好,向大家推荐。 331 | 332 | 算法引入两个变量id和mx,id表示最长回文子串的中心位置,mx表示最长回文字串的边界位置,即:mx=id+P[id]。 333 | 334 | 在这里有一个非常有用而且神奇的结论:如果mx > i,那么P[i] >= MIN(P[2 * id - i], mx - i) 分开理解就是: 335 | 336 | >1. 如果mx - i > P[j], 则P[i]=P[j] 337 | 2. 否则,P[i] = mx - i. 338 | 339 | 这两个该如何理解呢?具体的解释请看下面的两个图。 340 | 341 | (1)当 mx - i > P[j] 的时候,以S[j]为中心的回文子串包含在以S[id]为中心的回文子串中,由于 i 和 j 对称,以S[i]为中心的回文子串必然包含在以S[id]为中心的回文子串中,所以必有 P[i] = P[j],见下图。 342 | 343 | ![](http://upload-images.jianshu.io/upload_images/46178-f416d67d4d9ec2f9.png) 344 | 345 | 346 | (2)当 P[j] >= mx - i 的时候,以S[j]为中心的回文子串不一定完全包含于以S[id]为中心的回文子串中,但是基于对称性可知,下图中两个绿框所包围的部分是相同的,也就是 说以S[i]为中心的回文子串,其向右至少会扩张到mx的位置,也就是说 P[i] >= mx - i。至于mx之后的部分是否对称,就只能老老实实去匹配了。 347 | 348 | 349 | ![](http://upload-images.jianshu.io/upload_images/46178-6333e1f9b7670b42.png) 350 | 351 | 352 | 对于 mx <= i 的情况,无法对 P[i]做更多的假设,只能P[i] = 1,然后再去匹配了。 353 | 354 | 理解了上面的一点,就没有问题了。 355 | 356 | Source Code: 357 | ```java 358 | #include 359 | #include 360 | #include 361 | 362 | int longestPalSubstr(char *str) 363 | { 364 | char s[100]; 365 | int i, maxLen = 1, start = 0, j; 366 | int len = strlen(str); 367 | int mx = 0, id = 0, min; 368 | 369 | s[0] = '$'; 370 | s[1] = '#'; 371 | for(i = 0, j = 2; i < len; i++, j += 2) 372 | { 373 | s[j] = str[i]; 374 | s[j + 1] = '#'; 375 | } 376 | s[j] = '\0'; 377 | 378 | len = len * 2 + 1; 379 | int *p = (int *)malloc(sizeof(int) * len); 380 | memset(p, 0, len); 381 | p[0] = 1; 382 | 383 | for(i = 1; i < len; i++) 384 | { 385 | min = p[2 * id - i] > (mx - i) ? (mx - i) : p[2 * id - i]; 386 | p[i] = mx > i ? min : 1; 387 | while(s[i + p[i]] == s[i - p[i]]) 388 | { 389 | p[i]++; 390 | } 391 | if(i + p[i] > mx) 392 | { 393 | mx = i + p[i]; 394 | id = i; 395 | } 396 | } 397 | 398 | for(i = 0; i < len; i++) 399 | { 400 | //printf("%d ", p[i]); 401 | if(maxLen < p[i] - 1) 402 | { 403 | maxLen = p[i] - 1; 404 | start = i - maxLen; 405 | } 406 | } 407 | 408 | printf("The longest palin substr is "); 409 | for(i = start; i < start + 2 * maxLen + 1; i++) 410 | { 411 | if(s[i] != '#') 412 | { 413 | printf("%c", s[i]); 414 | } 415 | } 416 | printf(", maxlen is %d\n\n", maxLen); 417 | 418 | return maxLen; 419 | } 420 | 421 | int main() 422 | { 423 | char str[100]; 424 | 425 | while(1) 426 | { 427 | gets(str); 428 | if(strlen(str) == 0) break; 429 | longestPalSubstr(str); 430 | } 431 | 432 | return 0; 433 | } 434 | ``` 435 | 436 | **3. 坐标轴上从左到右依次的点为a[0]、a[1]、a[2]……a[n-1],设一根木棒的长度为L,求L最多能覆盖坐标轴的几个点?** 437 | 438 | **算法思想**:开始时我把题目理解错了,以为是求a中最大子序列和使其等于L,实际上是求满足a[j]-a[i] <= L && a[j+1]-a[i] > L这两个条件的j与i中间的所有点个数中的最大值,即j-i+1最大,这样题目就简单多了,方法也很简单:直接从左到右扫描,两个指针i和j,i从位置0开始,j从位置1开始,如果a[j] - a[i] <= L则j++并记录中间经过的点个数,如果a[j] - a[i] > L则j--回退,覆盖点个数-1回到刚好满足条件的时候,将满足条件的最大值与所求最大值比较,然后i++,j++直到求出最大的点个数。 439 | 440 | 有两点需要注意: 441 | 442 | >(1)这里可能没有i和j使得a[j] - a[i]刚好等于L的,所以判断条件不能为a[j] - a[i] = L。 443 | (2)可能存在不同的覆盖点但覆盖的长度相同,此时只选第一次覆盖的点。 444 | 445 | Source code: 446 | 447 | // 求最大覆盖点 448 | 449 | #include 450 | 451 | int maxCover(int a[], int n, int L) 452 | { 453 | int count = 2, maxCount = 1, start; 454 | int i = 0, j = 1; 455 | 456 | while(i < n && j < n) 457 | { 458 | 459 | while((j < n) && (a[j] - a[i] <= L)) 460 | { 461 | j++; 462 | count++; 463 | } 464 | 465 | // 退回到满足条件的j 466 | j--; 467 | count--; 468 | 469 | if(maxCount < count) 470 | { 471 | start = i; 472 | maxCount = count; 473 | } 474 | i++; 475 | j++; 476 | } 477 | 478 | printf("covered point: "); 479 | for(i = start; i < start + maxCount; i++) 480 | { 481 | printf("%d ", a[i]); 482 | } 483 | printf("\n"); 484 | 485 | return maxCount; 486 | } 487 | 488 | int main() 489 | { 490 | // test 491 | int a[] = {1, 3, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 21}; 492 | 493 | printf("max count: %d\n\n", maxCover(a, 13, 8)); 494 | 495 | int b[] = {1,2,3,4,5,100,1000}; 496 | 497 | printf("max count: %d\n", maxCover(b, 7, 8)); 498 | 499 | return 0; 500 | } 501 | 502 | 503 | ![5.png](http://upload-images.jianshu.io/upload_images/46178-028b9ea66d33119c.png) 504 | 505 | 506 | published from :[百度2014研发类校园招聘笔试题解答 - Alexia(minmin) - 博客园](http://www.cnblogs.com/lanxuezaipiao/p/3356624.html) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | --------------------------------------------------------------------------------