文章

16

粉丝

50

获赞

1

访问

3.1k

头像
字符串排序 题解:题目要求多组,许多通过没有这个也过了
P1254 北京大学机试题
发布于2024年3月12日 21:33
阅读数 201

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int cmpa(const void *a,const void *b)
{
     return strcmp((char*)a,(char*)b);
}
int main()
{
    int n;
     char a[20];
    while(scanf("%s",a)!=EOF)
    {
        n=strlen(a);
      qsort(a,n,sizeof(char),cmpa);
    for(int m=0;m<n;m++)
    {
        printf("%c",a[m]);
    }
    printf("\n");
    }
 }


 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发