All pastes #590889 Raw Edit

Untitled

public text v1 · immutable
#590889 ·published 2007-06-26 20:51 UTC
rendered paste body
void set_right()
{
  short int icount, irigh_colors=0, itotal_right=0, icolor_count[2][iuse_sticks];
  
  for(icount=0; icount<max_sticks; icount++)
  {
    icolor_count[0][icount]=0; //User Anzahl an einer bestimmten Farbe
    icolor_count[1][icount]=0; //Zufall
  }
  
  for(icount=0; icount<iuse_sticks; icount++)
  {
    icolor_count[0][irow[ipass][icount]]++;  //Zählen wie oft jede einzelne Farbe bei der Usereingabe vorkommt
  }
  
  for(icount=0; icount<iuse_sticks; icount++)
  {
    icolor_count[1][iguess[icount]]++; //Selbes bei der Zufallskombination machen
  }
  for(icount=0; icount<iuse_colors; icount++)
  {
      if(icolor_count[1][icount]>=icolor_count[0][icount])
      {
        irigh_colors+=icolor_count[1][icount]-(icolor_count[1][icount]-icolor_count[0][icount]);  // Anzahl der weißen Stifte ermitteln, Schwarze werden jedoch auch mitgezählt
      }
      else
      {
        irigh_colors+=icolor_count[1][icount];
      }
  }
  
  for(icount=0; icount<iuse_sticks; icount++)
  {
    if(irow[ipass][icount]==iguess[icount]) //Komplette Übereinstimmungen (Schwarze Stifte) zählen
  	{
  	  itotal_right++;
    }
  }
  irigh_colors=irigh_colors-itotal_right; // Schwarze von den Weißen abziehen, da jeder Schwarze auch ein Weißer sein könnte da die Farbe ja stimmt
  iset_right[ipass][0]=itotal_right; // Im globalen Array speichern um für andere Funktionen zugänglich zu machen
  iset_right[ipass][1]=irigh_colors;
}