2012年3月25日

经典排序之插入排序

摘要: 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 using namespace std; 5 6 int main() 7 { 8 int i,j,tem; 9 int length;10 int a[]={2,43,24,19,25,39,11,6,5};11 // length = a.length();12 length = sizeof(a)/sizeof(int);13 cout<<length<<endl;14 printf(" 阅读全文

posted @ 2012-03-25 12:37 NewPanderKing 阅读(212) 评论(0) 推荐(0) 编辑

经典排序之快排--数组模拟快排

摘要: 1 #include <stdio.h> 2 3 int partition(int *a,int low ,int high) 4 { 5 int privotpos; 6 int tem = a[low]; 7 privotpos = a[low]; 8 while(low<high) 9 {10 while(low<high && a[high]>=privotpos)high--;11 a[low] = a[high];12 while(low<high && a[low]<=privotpos... 阅读全文

posted @ 2012-03-25 12:33 NewPanderKing 阅读(724) 评论(0) 推荐(0) 编辑

经典排序之选择排序

摘要: #include <stdio.h>int main(){ int i,j,index,k; int tem,length; int a[10]={2,24,3,19,45,12,1,66,34,7};// length = a.length(); length = 10; printf("Before ordered:\n"); for(i = 0; i < length; i++) printf("%d ",*(a+i)); printf("\n\n"); for(i = 0; i < length; i+ 阅读全文

posted @ 2012-03-25 12:27 NewPanderKing 阅读(202) 评论(0) 推荐(0) 编辑

经典排序之冒泡排序代码

摘要: 1 #include <stdio.h> 2 int main() 3 { 4 int i,j,k; 5 int tem,length; 6 int a[10]={2,24,3,19,45,12,1,66,34,7}; 7 // length = a.length(); 8 length = 10; 9 printf("Before ordered:\n");10 for(i = 0; i < length; i++)11 printf("%d ",*(a+i));12 printf("\n\n");13 for(. 阅读全文

posted @ 2012-03-25 12:25 NewPanderKing 阅读(424) 评论(0) 推荐(0) 编辑

关于cout计算顺序,从右到左计算顺序。

摘要: 1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 const int a[] = {10,20,30}; 7 const int *p = a; 8 cout<<"*p:"<<*p<<endl; 9 cout<<"*p:"<<*p<<"\t*p++:"<<*p++<<"\t*p"<<*p<<endl; 1 阅读全文

posted @ 2012-03-25 12:15 NewPanderKing 阅读(1888) 评论(0) 推荐(0) 编辑

导航