摘要: 1 #include 2 using namespace std; 3 4 static int daytable[2][13] ={ 5 {0,31,28,31,30,31,30,31,31,30,31,30,31}, 6 {0,31,29,31,30,31,30,31,31,30,31,30,31} 7 }; 8 //返回某年某月的某天是该年的第多少天 9 int day_of_year(int year ,int month,int day)10 {11 int i,leap;12 leap = ((year %4 ==0 && year%100 !=... 阅读全文
posted @ 2013-09-17 21:52 Big.Eagle 阅读(447) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;//快速排序算法实现//挖坑+分治法void quick_sort(int v[] ,int left,int right){ //int x = v[left]; if (left = x )//先从后往前找比x小的数 { j--; } if ( i < j ) //找到,填充前面那个坑 { v[i++] = v[j]; } //从前... 阅读全文
posted @ 2013-09-17 14:50 Big.Eagle 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 //在数组v中查找x,返回x在v中的下标,找不到返回-1 5 int binsearch(int v[],int n,int x) 6 { 7 int low = 0 , high = n - 1; 8 int mid ;//= (low + high)/2; 9 while (low v[mid])18 {19 low = mid +1;20 }21 else22 {23 r... 阅读全文
posted @ 2013-09-17 13:44 Big.Eagle 阅读(160) 评论(0) 推荐(0) 编辑