|
The landlord did not say what to do with 0, it is temporarily positive
void f(int a[], int n){
int i=0,j;/*i find positive numbers, j find negative numbers*/
while(i<n&&a[i]<0)i++;/*First positive number*/
for(j=i+1;j<n;j++)
if(a[j]<0){
int temp = a[i];
a[i] = a[j];
a[j] = temp;
i++; /* Both i and j are positive numbers, i is the first positive number */
}
} |
|