2011年9月1日

摘要: a. string x; // 调用default constructorb. string x = 10; // 调用constructor parameterized by int,这条语句相当于string x(10);c. string x = "abc"; // 调用constructor parameterized by const char *,这条语句相当于string x("abc");d. x = "xyz"; // 调用assign operatore. string c = a + b; // 先调用add o 阅读全文
posted @ 2011-09-01 11:45 chihits 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 1. <stdio.h>scanfprintfputchar()getchar() = fgetc(stdin)gets(buf) = fgets(buf, MAXN, stdin)note that gets is deprecated in C2. <ctype.h>isalphaisdigitisprinttolowertoupper3. <string.h>strchr,在字符串中查找字符strcpy,字符串拷贝strcmp,字符串比较,0 return value indicates equalitystrcat,字符串连接sscanf,从字符串输 阅读全文
posted @ 2011-09-01 11:40 chihits 阅读(156) 评论(0) 推荐(0) 编辑

2011年5月2日

摘要: 1. 用作Priority Queue,这个很经典了。不说了。2. 把多个有序容器里面的元素合并到一个大的有序容器里面。假设有n个有序容器,我们希望把这些容器里面的元素有序地放到一个大容器里面去。我们姑且称n个有序容器为小容器。对每个小容器维护一个cursor,cursor刚开始指向小容器中的第一个元素,即最小的元素。每个循环中,对n个cursor指向的n个元素建立一个最小堆;从这个堆里面extract最小的元素加到大容器里面;被extract最小元素的那个小容器的cursor往后挪一位;进入下一个循环。如果一个容器的cursor到达end了,那么最小堆的大小减一。因为我们每次加入到大容器里面 阅读全文
posted @ 2011-05-02 04:12 chihits 阅读(977) 评论(0) 推荐(0) 编辑

2011年3月18日

摘要: A short summary of Chapter 6 Heapsort from Introduction to Algorithms1. What is a binary heap?A binary heap is a nearly complete binary tree that has the max(min) heap property:each node is greater than or equal to any of its children. As a result, the maximum(minimum) element in a max(min) heap is 阅读全文
posted @ 2011-03-18 02:54 chihits 阅读(321) 评论(0) 推荐(0) 编辑

导航