#include "sort.h"
-
#define NUM_SHOWN 3
//#define DEBUG
-
void printlist(FILE * stream, int list_size, double *list, int num_shown)
{
int i;
if (num_shown > 0) {
- if (num_shown > list_size/2)
- num_shown = list_size/2;
+ if (num_shown > list_size / 2)
+ num_shown = list_size / 2;
for (i = 0; i < num_shown; i++)
fprintf(stream, "%g\t", list[i]);
fprintf(stream, "...\n...\t");
// read in the data
#ifdef DEBUG
fprintf(stderr, "reading %d points\n", *pList_size);
-#endif /* DEBUG */
+#endif /* DEBUG */
for (i = 0; i < *pList_size; i++) {
fscanf(fp, "%lf", &x);
(*pList)[i] = x;
char *file_name = "-";
#ifdef DEBUG
int i;
-#endif /* DEBUG */
+#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));
-#endif /* DEBUG */
+#endif /* DEBUG */
/* sort the list */
sort(list_size, list);
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);
- }
+ 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 */
+#endif /* DEBUG */
printlist(stdout, list_size, list, 0);