摘要:
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)
编辑
摘要:
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
吃吃户
阅读(174)
推荐(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
吃吃户
阅读(278)
推荐(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
吃吃户
阅读(178)
推荐(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
吃吃户
阅读(147)
推荐(0)
编辑