对字符串排序

#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<bitset>
#include<string>
#include<climits>
#include<cstdio>
#include<vector>
#include<utility>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define IN puts("in")
#define OUT puts("out")
#define FRR(x) freopen(x,"r",stdin)
#define FW(x) freopen(x,"w",stdout)
#define MSET(x,y) memset(x,y,sizeof(x))
#define ST system("pause")
#define lowbit(x) (x)&(-x)
#define LL(x) (x)<<1
#define RR(x) ((x)<<1)^1
using namespace std;

int cmp(const void *a, const void *b) {
    return strcmp( (const char *)a, (const char *)b );
}
const int maxn = 100005;
char as[maxn][31],bs[maxn][31];
int main()
{
        int i,j,k,n;
        while(scanf("%d",&n)==1)
        {
                for(i = 0; i < n; ++ i){
                        scanf("%s",as[i]);
                        strcpy(bs[i],as[i]);
                        strrev(bs[i]);
                }
                qsort(as,sizeof(as[0])*n,sizeof(as[0]),cmp);
                qsort(bs,sizeof(bs[0])*n,sizeof(bs[0]),cmp);
        }return 0;
}

posted on 2012-07-11 21:11  aigoruan  阅读(203)  评论(0)    收藏  举报

导航