-
Notifications
You must be signed in to change notification settings - Fork 0
/
源.c
32 lines (32 loc) · 770 Bytes
/
源.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
//Example:String sort
#include<stdio.h>
#include<string.h>
#define limmite 5
#define litter 80
void sort(char*[]);
int main(void)
{
char ptr[limmite][litter];
char *after[limmite];
int count;
puts("Please enter 5 sentence.I will help you sort them.");
for (count = 0; count < limmite&&gets(ptr[count])&&ptr[count][0]!='\n'; count++)
after[count]=ptr[count];
sort(after);
for (count = 0; count < limmite; count++)
puts(after[count]);
return 0;
}
void sort(char*after[])
{
char*temp;
int top, seek;
for(top =0; top<limmite-1; top++)
for(seek=top+1;seek<limmite;seek++)
if (strcmp(after[top], after[seek])>0)//ËùÒÔ˵Ϊʲôif (strcmp(after[top], after[seek]))ÎÞЧ£¿
{
temp = after[top];
after[top] = after[seek];
after[seek] = temp;
}
}