#include<stdio.h> #include<stdlib.h> #include<string.h> int cmp(const void *a,const void *b){ return strcmp((char*)a,(char*)b); } char s[1000][1000]; int main(int argc, char *argv[]) { while(~scanf("%s",s[0])) { int len=strlen(s[0]); for(int i=1;i<len;++i) { strcpy(s[i],s[0]+i); } qsort(s,len,1000,cmp); for(int i=0;i<len;++i) { printf("%s\n",s[i]); } } return 0; } /************************************************************** Problem: 1099 User: kirchhoff Language: C Result: Accepted Time:0 ms Memory:1888 kb ****************************************************************/
原文地址:http://blog.csdn.net/wdkirchhoff/article/details/42241549