Advertisement

PTA 6-4 字符串排序(20 分)

阅读量:

将N个字符串从键盘输入(约定:每个字符串的字符数量不超过80字节),随后对其进行升序排列,并最终输出结果。

函数接口定义与规范

复制代码
    int Input(char*pstr[], int N);
    void sort_Str(char **p);
    
    
    AI写代码c
    
    运行

裁判测试程序样例:

复制代码
    #include<stdio.h>
    #include<string.h>
    
    #define N 5
    
    int Input(char*pstr[], int N);
    void sort_Str(char *src[]);
    
    int main(void)        
    {
    int i;
    char *pstr[N], str[N][81];
    
    for (i=0; i<N; i++)
    {
        pstr[i] = str[i];
    }
    
    for (i=0; i<N; i++) 
    {
        gets(pstr[i]);
    }
    
    sort_Str(pstr);
    
    for (i=0; i<N; i++)

全部评论 (0)

还没有任何评论哟~