字典序模版

  例题hduJudging Troubles

#include <algorithm>

struct node  //必须是结构体
{
    char ch[20];
};
node ch1[100005],ch2[100005];
int comp(node a,node b)
{
    return strcmp(a.ch,b.ch)<0;
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    scanf("%s",ch1[i].ch);
    sort(ch1,ch1+n,comp);
    for(int i=0;i<n;i++)
    cout<<ch1[i].ch<<endl;

}
原文地址:https://www.cnblogs.com/dshn/p/4750506.html