title: Position of an element in a multidimensional array [ C ]
body: <p>I have to write a function that receives an integer X (the value of the linearized position)  and an array that contains the dimensions of a multidimensional array and it has to save in a second array the coordinates of the element with position X in the multidimensional reference system. For example:</p>
  
  <p>X=2 and array[]={A,B} where the array contains the dimensions(A,B) of a 2D matrix in this example. So the position in 2D reference system is:</p>
  
  <p>Knowing:  <strong>X=x*B+y</strong> ----> <strong>x=X/B</strong>  and  <strong>y=X%B</strong> ----> <strong>position[]={x,y};</strong></p>
  
  <p>So it was simple to decipher X into x and y because it was the banal case of a 2D matrix but my program has to deal with N-dimensional matrix (So it has to decipher X into position x,y,......,n) .</p>
  
  <p>My idea is to apply the algorithm that I've showed but even I can't find a C code that can deal with a generic N-dimensional matrix (I also tried to write a recursive function without success).</p>
  
  <p>Can someone find a solution to this problem? (Thank you in advance!!!)</p>
  
  <p>I'm a beginner!!!</p>