上一页 1 ··· 69 70 71 72 73 74 75 76 77 ··· 79 下一页
摘要: #include <iostream>using namespace std;void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}int partition(int *a,int p,int r){ int x=a[r]; int i=p-1; for (int j=p;j<r;j++) { if (a[j]<=x) { i=i+1; exchange(a[i],a[j]); } } ... 阅读全文
posted @ 2012-02-18 21:14 Dsp Tian 阅读(605) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;int parent(int i){ return i/2;}int left(int i){ return 2*i;}int right(int i){ return 2*i+1;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}//但就算法来看,heap_size(堆的大小)设为全局变量也许会好一些void max_heapify(int *a,int i,int heap_size){ in... 阅读全文
posted @ 2012-02-17 21:46 Dsp Tian 阅读(452) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;int main(){ int b[]={1,2,3}; int *a; a=(int*)malloc(sizeof(int)*3); memcpy(a,b,sizeof(int)*3); for (int i=0;i<3;i++) cout<<a[i]<<""; cout<<endl; system("pause"); free(a); return 0;} 阅读全文
posted @ 2012-02-17 21:36 Dsp Tian 阅读(500) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;void process(int *a){ a=(int*)realloc(a,sizeof(int)*4); a[3]=3;}int main(){ int *a; a=(int*)malloc(sizeof(int)*3); a[0]=0; a[1]=1; a[2]=2; process(a); for (int i=0;i<4;i++) cout<<a[i]<<""; cout<<endl; system("pause" 阅读全文
posted @ 2012-02-17 21:17 Dsp Tian 阅读(495) 评论(0) 推荐(0)
摘要: #include <iostream>#include <time.h>#include <stdlib.h>using namespace std;int random(int a,int b){ srand(NULL); return rand()%(b-a)+a;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}int main(){ int a[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14}; int length=sizeof(a)/ 阅读全文
posted @ 2012-02-17 19:00 Dsp Tian 阅读(560) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;int parent(int i){ return i/2;}int left(int i){ return 2*i;}int right(int i){ return 2*i+1;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}void max_heapify(int *a,int i,int heap_size){ int l=left(i); int r=right(i); i... 阅读全文
posted @ 2012-02-17 18:59 Dsp Tian 阅读(462) 评论(0) 推荐(0)
摘要: #include <iostream>#include <cmath>#include <vector>using namespace std;void main(){ double area=50; double R=0; int line; cin>>line; int i; double x,y; vector<double> dist; vector<double>::iterator dit; vector<int> res; vector<int>::iterator rit; for 阅读全文
posted @ 2012-02-09 17:23 Dsp Tian 阅读(445) 评论(0) 推荐(0)
摘要: #include <iostream>#include <vector>using namespace std;void main(){ int i; int month=12; double mean=0; double num; vector<double> vect; vector<double>::iterator vit; for (i=0;i<month;i++) { cin>>num; vect.push_back(num); } for (vit=vect.begin();vit!=vect... 阅读全文
posted @ 2012-02-09 15:25 Dsp Tian 阅读(491) 评论(0) 推荐(0)
摘要: #include <iostream>#include <string>using namespace std;void main(){ string card="card(s)"; double num=2; double res=0; double end; cin>>end; int what=0; while (res<=end) { res+=1/(num++); what++; } if (end>0) cout<<what<<" "<<card<< 阅读全文
posted @ 2012-02-09 15:10 Dsp Tian 阅读(406) 评论(0) 推荐(0)
摘要: #pragma warning (disable:4786)#include <iostream>#include <map>#include <algorithm>#include <string>#include <vector>using namespace std;typedef struct { string first; int second;}res;bool less_first(res tmp1,res tmp2){ return tmp1.first<tmp2.first;}bool my_equal(res 阅读全文
posted @ 2012-02-09 13:12 Dsp Tian 阅读(496) 评论(0) 推荐(0)
上一页 1 ··· 69 70 71 72 73 74 75 76 77 ··· 79 下一页