摘要: #includeusing namespace std;void insertSort(int arr[],int length,int record[]){ int max,pos; for(int k=0;kmax){ max=arr[j]; pos=j; } } arr[pos]=0; record[length-k-1]=pos; }}int main(){ int arr[]={2,5,3,7,1,6}; int arr_len=s... 阅读全文
posted @ 2014-02-19 20:12 开心成长 阅读(239) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;struct nums{int values[2];};static nums realVal;static nums formVal;struct nums getVal(int val1,int val2){ struct nums myvalue; if(val1>val2){ myvalue.values[0]=val1; myvalue.values[1]=val2; } else{ myvalue.values[0]=val2; myvalue.values[1]=val1; } return myvalue;}str. 阅读全文
posted @ 2013-09-23 22:48 开心成长 阅读(1290) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int maxi(int A[],int low,int high){ if(low==high) return A[low]; int low_max=maxi(A,low,(low+high)/2); int high_max=maxi(A,(low+high)/2+1,high); if(low_max>high_max) return low_max; else return high_max;}int main(){ int A[]={5,10,9,7... 阅读全文
posted @ 2013-09-20 10:14 开心成长 阅读(428) 评论(0) 推荐(0) 编辑
摘要: /*PROB:crypt1LANG:C++*/#include#includeusing namespace std;int main(){ ifstream fin("crypt1.in"); ofstream fout("crypt1.out"); int n; int num[9]={0}; bool legal[10]={false}; int count=0; int a,b,c,d,e,f; int p1,p2,p3,p4; fin>>n; for(int i=0;i>num[i]; legal[num[i]... 阅读全文
posted @ 2013-08-13 10:11 开心成长 阅读(229) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;class small_pal{private: int len; int pose;public: small_pal(int len,int pose){ this->len=len; this->pose=pose; } int getLen(){ return len; } int getPose(){ return pose; } void setLen(int len){... 阅读全文
posted @ 2013-08-08 09:11 开心成长 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 很多时候,我感觉自己想出了一个解题的算法,如果我自己不动手实现的话,我给沙老师讲的时候,就会被挑出很多问题,找出不可行的地方。所以我自己的思维不是很严密,我必须自己在实现算法的过程中,发现问题并优化,然后才能给别人讲解清楚。 阅读全文
posted @ 2013-08-06 11:30 开心成长 阅读(129) 评论(0) 推荐(0) 编辑
摘要: /*PROB:barn1LANG:C++*/#include#includeusing namespace std;int partion(int arr[],int low,int high){ int pivot=arr[low]; int pivotkey=arr[low]; while(low=pivotkey) high--; arr[low]=arr[high]; while(lowarr[j]){ max=arr[i+1]; arr[i+1]=arr[j... 阅读全文
posted @ 2013-08-03 19:57 开心成长 阅读(237) 评论(0) 推荐(0) 编辑
摘要: int *space=new int[c-1];int top(int space[]){}作为函数参数传递时,如topMax(space);在topMax函数中使用space[i]可以取得space数组的所有元素值,但是不能在topMax函数中通过sizeof(space)\sizeof(space[0])来获得space数组的长度。只能把space数组的长度作为topMax()函数的参数传递进去。 阅读全文
posted @ 2013-08-03 17:31 开心成长 阅读(603) 评论(0) 推荐(0) 编辑
摘要: /*PROB:milkLANG:C++*/#include#includeusing namespace std;int partion(int arr[],int arr1[],int low,int high){ int pivot=arr[low]; int pivot1=arr1[low]; int pivotkey=arr[low]; while(low=pivotkey) high--; arr[low]=arr[high]; arr1[low]=arr1[high]; while(low>re... 阅读全文
posted @ 2013-08-03 10:55 开心成长 阅读(325) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int partion(int arr[],int low,int high){ int pivot=arr[low]; int pivotkey=arr[low]; while(low=pivotkey) high--; arr[low]=arr[high]; while(low<high && arr[low]<=pivotkey) low++; arr[high]=arr[low]; } arr[low]=pivot;... 阅读全文
posted @ 2013-08-03 09:41 开心成长 阅读(277) 评论(0) 推荐(0) 编辑