Ver Mensaje Individual
  #9  
Antiguo 07-03-2012
Jusar Jusar is offline
Miembro
NULL
 
Registrado: feb 2012
Posts: 17
Reputación: 0
Jusar Va por buen camino
Hasta el momento lo que tengo es esto codigo pero no logro eso siempre me puede generar o tres 1 o tres 0 o cuatros 1 o 0...

Código Delphi [-]
void __fastcall TForm1::Button1Click(TObject *Sender)
{
     int mat[2][2];
     for (int i=0;i<2;i++)
         for (int j=0;j<2;j++)
             mat[i][j]= 0;

     int w=0;
     for (int i=0;i<2;i++)
     {
         for (int j=0;j<2;j++)
         {
             int x = random(2);
             for (int a=0;a<2;a++)
             {
                 for (int b=0;b<2;b++)
                 {
                     if ( mat[a][b] == x)
                        w++;
                 }
             }
             if (w<2)
             {
                mat[i][j]=x;
                w=0;
             }
         }
     }

     Label1->Caption=mat[0][0];
     Label2->Caption=mat[0][1];
     Label3->Caption=mat[1][0];
     Label4->Caption=mat[1][1];

}
Responder Con Cita