1.vector sortԴ?源码elasticnet算法源码?
vector sortԴ??
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef struct student
{
int sorce;
char number[];
}st;
void sort(vector<st>&st)
{
int size=st.size();
for(int i=0;i<size-1;i++)
for(int j=i+1;j<size;j++)
{
if(st[i].sorce>st[j].sorce)
{
swap(st[i],st[j]);
}
}
}
void main()
{
vector<st> vt;
st s;
s.sorce=;
strcpy(s.number,"shao");
vt.push_back(s);
s.sorce=;
strcpy(s.number,"zhang");
vt.push_back(s);
for(vector<st>::iterator it=vt.begin();it!=vt.end();++it)
cout<<it->sorce<<" "<<it->number<<endl;
sort(vt);
cout<<"++++++++++++++++++++"<<endl;
for(it=vt.begin();it!=vt.end();++it)
cout<<it->sorce<<" "<<it->number<<endl;
}