0

HELP ME find the mistake

i have an array with number andi need a function that put the cero of the array at the end of it i tried with int*organizar(int*x,int n,int*y,int j,int i,int p){ if(n==p){return y; }else{ if(x[p]==0){ y[i]=x[p]; return organizar(x,n,y,j,i-1,p++); }else{ y[j]=x[p]; return organizar(x,n,y,j++,i,p++); } } }; int*ceros_alfinal(int*x, int n){ int*y = new int [n]; if(n==1){return x; }else{ return organizar(x,n,y,0,n-1,0); } }; but doesn´t run can you help me??

5th May 2017, 5:37 PM
Juan Diego Medina
Juan Diego Medina - avatar
2 ответов
+ 6
Fixed size not problem, you can use pointers and dinamic memory allocation. But better to use vector, if it is c++
5th May 2017, 6:42 PM
shaldem
shaldem - avatar
+ 3
So first of all where did you actually initialize the array or arrays, if you want your function to use arrays, you have to write the parameters with brackets and the array has to have a fixed size f.e. like this int n[3];
5th May 2017, 6:35 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar