摘要: #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 阅读(549) 评论(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 阅读(449) 评论(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 阅读(436) 评论(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 阅读(481) 评论(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 阅读(395) 评论(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 阅读(476) 评论(0) 推荐(0) 编辑
摘要: #include <string.h>#include <vector>#include <algorithm>#include <string>#include <iostream>using namespace std;void main(){ string m("----------asdfas--------------dfgdf---------"); string::iterator it; vector<char> csr; vector<char>::iterator cit 阅读全文
posted @ 2012-02-09 01:03 Dsp Tian 阅读(687) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;void main(){ string num; string strset1="."; string strset2="0"; int n; int wei; int sum_wei; cin>>num>>n; int first=num.find_first_of(strset1); if (fi 阅读全文
posted @ 2012-02-08 20:56 Dsp Tian 阅读(442) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std; void main(){ int a,b; cin>>a>>b; cout<<a+b<<endl;} 阅读全文
posted @ 2012-02-08 15:25 Dsp Tian 阅读(389) 评论(0) 推荐(0) 编辑
摘要: #include <string>#include <iostream>#include <algorithm>#include <vector>#include <fstream>using namespace std;int main(){ ifstream in("data.txt"); string strtmp; vector<string> vect; while (getline(in,strtmp,'\n')) vect.push_back(strtmp); copy(v 阅读全文
posted @ 2012-02-08 13:18 Dsp Tian 阅读(624) 评论(0) 推荐(0) 编辑