int main(int argc, char *argv[])
{
- int list_size, i;
+ int list_size;
double *list;
char *file_name = "-";
+#ifdef DEBUG
+ int i;
+#endif /* DEBUG */
// parse arguments
if (argc > 1)
printlist(stderr, list_size, list, NUM_SHOWN);
fprintf(stderr, "Check: sum of %d elements = %g\n",
list_size, checklist(list_size, list));
+ for (i=0; i < list_size-1; i++) {
+ if (list[i] > list[i+1]) {
+ fprintf(stderr, "Error: sorted list[%d] = %g > %g = list[%d]\n",
+ i, list[i], list[i+1], i+1);
+ exit(EXIT_FAILURE);
+ }
+ }
#endif /* DEBUG */
printlist(stdout, list_size, list, 0);