//快排模板
/**//*double */
#include<iostream>
#include<algorithm>
using namespace std;
int cmp( const void *a , const void *b )
{
return *(double *)a - *(double *)b;
}
int main()
{
double a[10]={1,5,6,5,4,9,7,8,6,0};
qsort(a,10,sizeof(a[0]),cmp);
for(int i=0;i<10;i++)
cout<<a[i]<<" ";
return 1;
}
*/
/**//*int
#include<iostream>
#include<algorithm>
using namespace std;
int cmp( const void *a , const void *b )
{
return *(int *)a - *(int *)b;
}
int main()
{
int a[10]={1,5,6,5,4,9,7,8,6,0};
qsort(a,10,sizeof(a[0]),cmp);
for(int i=0;i<10;i++)
cout<<a[i]<<" ";
return 1;
}
*/
/**//*char
#include<iostream>
#include<algorithm>
using namespace std;
int cmp( const void *a , const void *b )
{
return *(char *)a - *(char *)b;
}
int main()
{
char a[10]=
{'1','5','6','5','4','9','7','8','6','0'};
qsort(a,10,sizeof(a[0]),cmp);
for(int i=0;i<10;i++)
cout<<a[i]<<" ";
return 1;
}
*/
/**//*字符串
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int cmp(const void *p1,const void *p2)
{
return strcmp((char *)p1,(char *)p2);
}
int main()
{
char a[10][10]=
{"123","524","645","545","114","2129","765","878","656"
,"021"};
qsort(a,10,sizeof(a[0]),cmp);
for(int i=0;i<10;i++)
cout<<a[i]<<endl;
return 1;
}
*/
/**//*结构体
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct node
{
int d1;
int d2;
};
int cmp(const void *p1,const void *p2)
{
node *p=(node *)p1,*q=(node *)p2;
if(p->d1!=q->d1)
return (p->d1-q->d1);
return (p->d2-q->d2);
}
int main()
{
node a[10]={{1,3},{5,4},{6,5},{5,5},{1,4},{2,9},
{7,5},{8,8},{6,6},{0,1}};
qsort(a,10,sizeof(a[0]),cmp);
for(int i=0;i<10;i++)
cout<<a[i].d1<<a[i].d2<<endl;
return 1;
}
*/