/** * sort.c - A simple sorter. */ #include #include #include #include "array_utils.h" // +-----------+------------------------------------------------------ // | Constants | // +-----------+ /** The size of the array we use. */ #ifndef SIZE #define SIZE 1024 #endif // +------+----------------------------------------------------------- // | Main | // +------+ int main () { int result; int i; int len = 0; int values[SIZE]; int ch; // Read the values while ((len < SIZE) && (result = scanf ("%d", &(values[len]))) != EOF) { // Did we find a value? If so, our array is a bit bigger if (result == 1) ++len; // If we didn't find a value, we probably have a non-digit // character, so skip over it. else { ch = getchar (); printf ("Skipping '%c'\n", ch); } } // while // Sort the values selection_sort (values, len); // Print the result for (i = 0; i < len; i++) printf ("%d\n", values[i]); // And we're done return EXIT_SUCCESS; } // main