/* shellsort.c; cpl3.5 */ #include #define MAXLINE 1000 int getline(char s[], int lim); void crudesort (char v[], int n); char line[MAXLINE]; main() { int len; while (len = getline(line, MAXLINE)> 0) { crudesort(line, xx-1); /* don't sort \n */ printf("%s",line); } } void crudesort(char v[], int n) { int i, tmp; for(i=0; iv[i+1]) {/* out of order */ tmp=v[i]; v[i]=v[i+1]; v[i+1]=tmp; i=-1; } } } /* getline: read a line into s, return length */ /* Never returns a length of 0 - if length if > 0 then the line was stuffed into s[] and ended with a '\n\0'. If length==-1 then the line hit EOF as its first character. */ int getline(char s[], int lim) { int c, i; for (i=0; i