home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_06
/
9n06024b
< prev
next >
Wrap
Text File
|
1991-02-17
|
506b
|
32 lines
#include <stdio.h>
#include <string.h>
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
main()
{
char list[][7] = {
"red",
"blue",
"yellow",
"green"
};
int i, j;
char temp[7];
for (i = NUMELEM(list) - 2; i >= 0; --i) {
for (j = 0; j <= i; ++j) {
if (strcmp(list[j], list[j + 1]) > 0) {
strcpy(temp, list[j]);
strcpy(list[j], list[j + 1]);
strcpy(list[j + 1], temp);
}
}
}
for (i = 0; i < NUMELEM(list); ++i)
printf("%s\n", list[i]);
}