-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathE3.c
43 lines (39 loc) · 781 Bytes
/
E3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
E3.c
2022-11-02
Denta Bramasta
*/
#include <stdio.h>
#include <string.h>
char nama[501][11];
int list,i, j;
void strclear(int a)
{
nama[a][0]= '\0';
}
void swap(int a, int b)
{
char tmp[11];
strcpy(tmp, nama [a]);
strclear (a);
strcpy(nama [a] , nama [b]);
strclear (b);
strcpy(nama [b], tmp);
}
int main()
{
scanf ("%d", &list);
for(i=1; i<=list; i++)
scanf ("%s" , nama[i]);
for(i=1; i<=list-1; i++){
for (j=i; j<=list; j++){
if(strlen(nama[j])<strlen(nama[i]))
swap(j,i);
if(strlen(nama[j])==strlen (nama[i]) )
if(strcmp (nama[j],nama[i]) <0)
swap(j, i);
}
}
for(i=1; i<=list; i++)
printf("%s\n", nama[i]);
}