3474. Mysort

Easy函数普通指针排序

时间限制:1000 ms

内存限制:256 MiB

题面

#include<stdio.h>

/********** Specification of mysort **********/
void mysort(char *v[], int L, int R);
/* PreCondition:
      v points to an array of char*,
      L,R are indexes of the array to be sorted
   PostCondition:
      sort v with the ascending order of strings
      pointed by elements of the array pointed by v
*/

#define MAXLINES 5000
char *lineptr[MAXLINES];

void readlines(char *lineptr[], int nlines);

void writelines(char *lineptr[], int nlines);

int main() {
    int nlines;
    scanf("%d\n", &nlines);
    readlines(lineptr, nlines);
/********** mysort is called here *************************/
    mysort(lineptr, 0, nlines - 1);
/***********************************************************/
    writelines(lineptr, nlines);
    return 0;
}

输入格式

  • Line 1: nn (1n5 0001 \le n \le 5~000).
  • Line 2~n+1n+1: A non-empty string each line. Sum of lengths of all strings will not exceed 10610^6.

输出格式

Output the sorted strings.

样例

输入

7
a
b
c
d
ef
ee
bb

输出

a
b
bb
c
d
ee
ef