Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - For a given int array int array[n].

Place all elements in the array that are less than or equal to 0 at the front of the array, and those greater than 0 at the back

For a given int array int array[n].

Place all elements in the array that are less than or equal to 0 at the front of the array, and those greater than 0 at the back

void Change(int *pNum, int *pArray)

{

for(int i = 0; i < 10; i++)

{

if(*(pArray + i) > 0)

{

int iTemp = *pNum;

*pNum = *(pArray + i);

*(pArray + i) = iTemp;

}

}

}

int _tmain()

{

int iArray[10];

for(int i = 0; i < 10; i++)

cin>>iArray[i];

for(int i = 0; i < 10; i++)

{

< p> if(iArray[i] <= 0)

Change(&iArray[i],iArray);

}

for(int i = 0 ; i < 10; i++)

cout<

system("pause");

return 0;< /p>

}