sobota, 3 grudnia 2022

Mondial 2022 group C - TStringGrid - C++ Builder

 




struct mundial_2022
{
 AnsiString Name;
 int win_Goal;
 int los_Goal;
 int pkt;
}soccer_GroupC[4];;

 int __fastcall Result(int x, int y);
 void __fastcall write_Match(AnsiString team1,AnsiString team2,int goal1,int goal2,int rows);
 void __fastcall date_Team1();


__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
  soccer_GroupC[0].Name="Argentina";
  soccer_GroupC[1].Name="Poland";
  soccer_GroupC[2].Name="Mexico";
  soccer_GroupC[3].Name="Saudi Arabia";
  for(int i=0;i<4;i++)
  {
   soccer_GroupC[i].win_Goal=0;
   soccer_GroupC[i].los_Goal=0;
   soccer_GroupC[i].pkt=0;
  }
}

int __fastcall TForm1::Result(int x, int y)
{
 int pkt;
 if(x>y)
  pkt=3;
 else if(x<y)
  pkt=0;
 else
  pkt=1;
 return pkt;
}
void __fastcall TForm1::write_Match(AnsiString team1,AnsiString team2,int goal1,int goal2,int rows)
{
  StringGrid1->Cells[0][rows]=team1;
  StringGrid1->Cells[1][rows]=team2;
  StringGrid1->Cells[2][rows]=IntToStr(goal1);
  StringGrid1->Cells[3][rows]=IntToStr(goal2);
}
void __fastcall TForm1::date_Team1()
{

  int goals_Arg[6]={1,2,2,0,2,0};
  int w,l;
  w=l=0;
  soccer_GroupC[0].pkt+=Result(goals_Arg[0],goals_Arg[1]);
  soccer_GroupC[0].pkt+=Result(goals_Arg[2],goals_Arg[3]);
  soccer_GroupC[0].pkt+=Result(goals_Arg[4],goals_Arg[5]);
  w=goals_Arg[0]+goals_Arg[2]+goals_Arg[4];
  l=goals_Arg[1]+goals_Arg[3]+goals_Arg[5];
  soccer_GroupC[0].win_Goal=w;
  soccer_GroupC[0].los_Goal=l;

  int goals_Pol[6]={0,0,2,0,0,2};
  w=l=0;
  soccer_GroupC[1].pkt+=Result(goals_Pol[0],goals_Pol[1]);
  soccer_GroupC[1].pkt+=Result(goals_Pol[2],goals_Pol[3]);
  soccer_GroupC[1].pkt+=Result(goals_Pol[4],goals_Pol[5]);
  w=goals_Pol[0]+goals_Pol[2]+goals_Pol[4];
  l=goals_Pol[1]+goals_Pol[3]+goals_Pol[5];
  soccer_GroupC[1].win_Goal=w;
  soccer_GroupC[1].los_Goal=l;

  int goals_Mex[6]={0,0,0,2,2,1};
  w=l=0;
  soccer_GroupC[2].pkt+=Result(goals_Mex[0],goals_Mex[1]);
  soccer_GroupC[2].pkt+=Result(goals_Mex[2],goals_Mex[3]);
  soccer_GroupC[2].pkt+=Result(goals_Mex[4],goals_Mex[5]);
  w=goals_Mex[0]+goals_Mex[2]+goals_Mex[4];
  l=goals_Mex[1]+goals_Mex[3]+goals_Mex[5];
  soccer_GroupC[2].win_Goal=w;
  soccer_GroupC[2].los_Goal=l;

  int goals_Sau[6]={2,1,0,2,1,2};
  w=l=0;
  soccer_GroupC[3].pkt+=Result(goals_Sau[0],goals_Sau[1]);
  soccer_GroupC[3].pkt+=Result(goals_Sau[2],goals_Sau[3]);
  soccer_GroupC[3].pkt+=Result(goals_Sau[4],goals_Sau[5]);
  w=goals_Sau[0]+goals_Sau[2]+goals_Sau[4];
  l=goals_Sau[1]+goals_Sau[3]+goals_Sau[5];
  soccer_GroupC[3].win_Goal=w;
  soccer_GroupC[3].los_Goal=l;


}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{

 write_Match(soccer_GroupC[0].Name,soccer_GroupC[3].Name,1,2,0);
 write_Match(soccer_GroupC[1].Name,soccer_GroupC[2].Name,0,0,1);
 write_Match(soccer_GroupC[3].Name,soccer_GroupC[1].Name,0,2,2);
 write_Match(soccer_GroupC[2].Name,soccer_GroupC[0].Name,0,2,3);
 write_Match(soccer_GroupC[1].Name,soccer_GroupC[0].Name,0,2,4);
 write_Match(soccer_GroupC[2].Name,soccer_GroupC[3].Name,2,1,5);
 date_Team1();
 for(int i=0;i<4;i++)
 {
  StringGrid2->Cells[0][i]=soccer_GroupC[i].Name;
  StringGrid2->Cells[1][i]=IntToStr(soccer_GroupC[i].pkt);
  StringGrid2->Cells[2][i]=IntToStr(soccer_GroupC[i].win_Goal);
  StringGrid2->Cells[3][i]=IntToStr(soccer_GroupC[i].los_Goal);
 }
}
//---------------------------------------------------------------------------



Brak komentarzy:

Prześlij komentarz