Original question
Store any n integers in array A, write programs, and rank all integers before all negative numbers.
Ideas
The question is super watery, and the code is directly written.
Implementation Code
/*************************************** * *********************************> File Name: testmain. c> author: krischou> mail: [email protected]> created time: mon 18 Aug 2014 12:26:34 am CST ********************************* ***************************************/ # include <stdio. h> # include <stdlib. h> # include <string. h> # include <time. h> void print (int * arr, int N); void partion (int * arr, int N); int Ma In (INT argc, char * argv []) {int size = atoi (argv [1]); int * arr = (int *) calloc (size, sizeof (INT); int index; srand (Time (null); For (Index = 0; index <size; index ++) {If (RAND () % 2 = 0) {arr [Index] = rand () % 100;} else {arr [Index] =-rand () % 100 ;}} print (ARR, size); partion (ARR, size); print (ARR, size); Return 0;} void print (int * arr, int N) {int index; for (Index = 0; index <n; index ++) {printf ("% 4D ", arr [Index]);} printf (" \ n ");}/*** if low ++ makes low and high meet, the left element of low is already in the correct position, and the right element of high (including high) is also in the correct position. Finish. * If high -- makes low and high meet each other, the low left element (including low) is already in the correct position, and the high right element is also in the correct position. Finish. */Void partion (int * arr, int N) {int low = 0; int high = n-1; int TMP; while (low