摘要: 1 #include <boost/graph/graph_traits.hpp> 2 #include <boost/graph/adjacency_list.hpp> 3 #include <boost/graph/dijkstra_shortest_paths.hpp> 4 using namespace boost; 5 6 #include <iostream> // for std::cout 7 #include <utility> // for std::pair 8 #include <algorithm> 阅读全文
posted @ 2011-11-10 10:22 吃吃户 阅读(630) 评论(0) 推荐(0) 编辑
摘要: C/C++是最主要的编程语言。这里列出了50名优秀网站和网页清单,这些网站提供c/c++源代码。这份清单提供了源代码的链接以及它们的小说明。我已尽力包括最佳的C/C++源代码的网站。这不是一个完整的清单,您有建议可以联系我,我将欢迎您的建议,以进一步加强这方面的清单。1、http://snippets.dzone.com/tag/c/--数以千计的有用的C语言源代码片段2、http://www.hotscripts.com/category/c-cpp/scripts-programs/Hotscripts--提供数以百计的C和C++脚本和程序。所有程序都分为不同的类别。3、http://ww 阅读全文
posted @ 2011-11-04 10:35 吃吃户 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 见http://hi.baidu.com/piaoshi111/blog/item/204db32596b8c93e8644f972.html 阅读全文
posted @ 2011-11-01 16:53 吃吃户 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 4 #include <stdio.h> 5 6 struct Node { 7 int data; 8 Node * next; 9 };10 // 非递归11 Node * Reverse(Node * first)12 {13 Node *p = first, *q, *r;14 if (p == NULL)15 return p;16 r = p->next;17 p->next = NULL;18 while (r... 阅读全文
posted @ 2011-10-28 17:23 吃吃户 阅读(376) 评论(0) 推荐(0) 编辑
摘要: 最基本的情况,给个10进制数,转化为2进制。。。 1 #include <stdio.h> 2 3 void Swap(char * a, int i, int j) 4 { 5 char temp = a[i]; 6 a[i] = a[j]; 7 a[j] = temp; 8 } 9 10 char * Ten2Two(int n)11 {12 static char data[100];13 int i = 0;14 while (n != 0) {15 data[i++] = n % 2 + '0';16 ... 阅读全文
posted @ 2011-10-27 18:02 吃吃户 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 1 #include <string.h> 2 #include <stdio.h> 3 4 int Gcd(int m, int n) 5 { 6 if (m < n) { 7 return Gcd(n, m); 8 } 9 10 if (n == 0) {11 return m;12 } else {13 return Gcd(n, m % n);14 }15 }16 17 int Gcd2(int m, int n)18 {19 if (m < n)20 retur... 阅读全文
posted @ 2011-10-22 21:04 吃吃户 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 1 #include <string.h> 2 #include <stdio.h> 3 4 5 void Swap(int * a, int i, int j) 6 { 7 int temp = a[i]; 8 a[i] = a[j]; 9 a[j] = temp;10 }11 12 void Heapify(int * a, int start, int end)13 {14 int index;15 if (2 * start + 2 <= end) {16 index = a[2 * start + 1] < a[2 * s... 阅读全文
posted @ 2011-10-22 18:41 吃吃户 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1 #include <string.h> 2 #include <stdio.h> 3 4 void Swap(int * a, int i, int j) 5 { 6 int temp = a[i]; 7 a[i] = a[j]; 8 a[j] = temp; 9 }10 11 int Partition(int * a, int start, int end)12 {13 int sentinal = a[start];14 while (start < end) {15 while (a[end] > sentinal && ... 阅读全文
posted @ 2011-10-22 15:30 吃吃户 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 1 #include <string.h> 2 #include <stdio.h> 3 4 void Swap(int * a, int i, int j) 5 { 6 int temp = a[i]; 7 a[i] = a[j]; 8 a[j] = temp; 9 }10 11 void Heapify(int * a, int start, int end)12 {13 int index;14 if (2 * start + 2 <= end) {15 index = a[2 * start + 1] > a[2 * star... 阅读全文
posted @ 2011-10-22 15:21 吃吃户 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 4 #include <stdlib.h> 5 #include <sys/types.h> 6 7 int CountOf1(u_int32_t n) 8 { 9 u_int32_t lower = 0;10 u_int32_t cur = 0;11 u_int32_t upper = 0;12 int count = 0;13 u_int32_t factor = 1;14 15 while (n / factor != 0) {16 ... 阅读全文
posted @ 2011-10-22 10:31 吃吃户 阅读(143) 评论(0) 推荐(0) 编辑