title: Selection Sort Counting comparisons
body: <p>i have a program with Selection Sort, which generates and sorts random numbers in ascending order and descending order. The problem is with the counting of comparisons. It gives correct number until 10 0000 numbers, but when i generate 100k numbers, it returns wrong value than the one from a formula.
  Here is my Selection Sort code.</p>
  
  <pre><code>void select (int n, float *pole2,int *compare,int *move,char decide)
  {
      *compare=0; // number of comparisons
      *move=0;
  
  int i; 
       for (i = 0; i &lt; n - 1; i++)
       {                              
           int j, poz_min;
           float temp,min;
           min = pole2[i];
           poz_min = i;//
           for (j = i+1; j &lt; n; j++)
           {  
                  *compare+=1;
                   if (pole2[j] &lt; min)
                   {  
                      min = pole2[j];
                      *move+=1;
                      poz_min=j;
                   }  
           }
           temp = pole2[i];
           pole2[i] = pole2[poz_min];
           pole2[poz_min] = temp;
           *move+=3;
       }
  
  
  // Writing to a binary file     
  
  FILE *fw;
      fw = fopen("Select_SORT.DAT", "wb+");
  int z;
  for(z = 0; z &lt; n; z++)
      {
          fwrite(&amp;pole2[z], sizeof(pole2[z]), 1, fw);
      }
   fclose(fw);
  
  
   fseek(fw, 0, SEEK_SET);
  
  
  }
  </code></pre>