+ 1
Question on arrays !! [ in description]
for example, the array 10 | 20 | 15 | 4 | 20 after execution of the program for the given integer 20 should become 0 | 0 | 10 | 15 | 4
1 ответ
0
I belive what your program does is finding a given number (in this case 20) and replace it with a 0 at the start of the array u can write a function that does this it should look like this
Void example(int *T, int n, int x) {
//this loop will put all the x's in the front of the array
For (i=n-1;i>=0;i--) {
If (T[i] ==x) {
j=i;
do{if(T[j-1]!=x) break; else j--;} while(j>=0)
}
T[i] =T[j-1] ;
T[j-1] =x;
}
//now set the x's to 0
For (i=0;i<n;i++) {
If (T[i] ==x)
T[i] =0;
}
Now in your main function call example(arr,5,20)
Good luck (sorry for my bad English )