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??
2 ответов
+ 6
Fixed size not problem, you can use pointers and dinamic memory allocation. But better to use vector, if it is c++
+ 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];