END_TEST START_TEST(test_array_order) { printf("Ordering data1 array\n"); size_t *indices = (size_t*)malloc(length*sizeof(size_t)); printf("Nominal p-values:\n"); array_printf(data1, length, "%f "); printf("\n"); BH_correction(data1, length); printf("BH p-adjust::\n"); array_printf(data1, length, "%f "); printf("\n\n"); data1[8] = INFINITY; data1[4] = NAN; array_order(data1, length, 0, indices); double *double_ordered = (double*)malloc(length*sizeof(double)); array_ordered(data1, length, indices, double_ordered); printf("Original with NaN and INFINITY:\n"); array_printf(data1, length, "%f "); printf("\n"); printf("Ordered desc:\n"); array_printf(double_ordered, length, "%f "); printf("\n"); printf("Ordered asc:\n"); array_order(data1, length, 1, indices); array_ordered(data1, length, indices, double_ordered); array_printf(double_ordered, length, "%f "); printf("\n\n"); free(indices); free(double_ordered); }
int main() { int x; int array[max]; do { printf("Enter number between 0 and 10:\n"); scanf("%d", &x); } while (x<=0 || x>=10); array_init(array); printf("Array before:\n"); array_print(array); array_order(array, x); printf("Array after order:\n"); array_print(array); return 0; }