title: Removing row and column of matrix after looking for a value (C)
body: <p>I made <a href="https://stackoverflow.com/questions/16518371/c-getting-the-3-minimum-elements-of-an-row-in-a-matrix-and-choose-one-randoml">a question</a> some hours ago but I get myself in a mess on what I had to do after finishing what I was asking on that question. All the solutions that the people gave me were ok, but useless for what I was really looking for as I didn't wrote the question as it has to be. I've to save an important position of a value, and it wasn't necessary to be saved on the other question to solve the problem. So here's the proper one.</p>
  
  <p>(everything's is explained with an example above, understanding it is easy) I've a 8x8 matrix, and after choosing the row I desire, I want to get the three minimum elements of it, and choose one of this three randomly. Then, remove the row and column that contains this number. The thing is that I'dont know how to handle those three elements and remove the columns/rows. I just know how to get the minimum element, that is the following code.</p>
  
  <pre><code>int pieza[ROWS][COLS] = {
  0, 2, 2, 5, 3, 2, 1, 1,
  0, 4, 5, 2, 4, 3, 0, 0,
  0, 4, 2, 2, 1, 2, 3, 2,
  0, 3, 1, 5, 1, 2, 3, 4,
  2, 5, 6, 5, 3, 1, 2, 7,
  8, 2, 0, 0, 0, 2, 1, 1,
  1, 2, 2, 1, 1, 6, 3, 4,
  0, 1, 3, 2, 0, 0, 0, 0,
  };
  
  int myrow = 3; // the row I want to analyze
  int index;
  int min=0;
  
  for (index=0;index&lt;8;index++) {
      printf("%d", piezas[myrow][index] );
      if(piezas[myrow][index]&lt;min)
          min=piezas[myrow][index];
      printf("\t\t");
  }
  printf("min: %d", min);
  </code></pre>
  
  <p>This is what I want to do. If the initial matrix is (which is always a <code>nxn</code> matrix):</p>
  
  <pre><code>{
  0, 2, 2, 5, 3, 2, 1, 1,
  0, 4, 5, 2, 4, 3, 0, 0,
  0, 4, 2, 2, 1, 2, 3, 2,
  0, 3, 1, 5, 1, 2, 3, 4,
  2, 5, 6, 5, 3, 1, 2, 7,
  8, 2, 0, 0, 0, 2, 1, 1,
  1, 2, 2, 1, 1, 6, 3, 4,
  0, 1, 3, 2, 0, 0, 0, 0,
  };
  </code></pre>
  
  <p>And I choose row number 3:</p>
  
  <pre><code>0, 3, 1, 5, 1, 2, 3, 4,
  </code></pre>
  
  <p>The algorithm must choose the three minimum elements of that row.</p>
  
  <pre><code>0, 1, 1
  </code></pre>
  
  <p>And choose randomly one of these three. If, for example, it choose the first 'one'...</p>
  
  <pre><code>0, **1**, 1
  </code></pre>
  
  <p>... the algorithm must go to the 3th column of that line (becaue that was the position that was that '1') and remove the row and column, so the output matrix will be as follows, one dimension less than the original matrix (beucase you have removed a row and a column):</p>
  
  <pre><code>    {
      0, 2, 5, 3, 2, 1, 1,
      0, 4, 2, 4, 3, 0, 0,
      0, 4, 2, 1, 2, 3, 2,
      2, 5, 5, 3, 1, 2, 7,
      8, 2, 0, 0, 2, 1, 1,
      1, 2, 1, 1, 6, 3, 4,
      0, 1, 2, 0, 0, 0, 0,
      };
  </code></pre>
  
  <p>I only know how to arrive to the line, but I'm having problems to handle three minimums because I'm having tons of problems pointers and I'm not a lot into C. <br> Thanks in advance</p>