提交记录 #198
提交时间:2024-11-12 19:36:14
语言:c
状态:Accepted
编译情况:编译成功
固定测试点#1:
额外测试点#3600:
35【字符】单词排序
#include<stdio.h>
#include<string.h>
#define maxw 5
#define maxl 1000
void bubble_sort(char word[maxw][maxl],int n){
char t[maxl];
for (int i=0;i<n-1;i++){
for (int j=0;j<n-i-1;j++){
if(strcmp (word[j],word[j+1])<0){
strcpy(t,word[j]);
strcpy(word[j],word[j+1]);
strcpy(word[j+1],t);
}
}
}
}
int main(){
char word[maxw][maxl];
for (int i=0;i<maxw;i++){
scanf("%s",word[i]);
}
bubble_sort(word,maxw);
for (int i=0;i<maxw;i++){
printf("%s\n",word[i]);
}
return 0;
}