A01 + A02+ A03 +A04= X
+ + + +
A05 + A06 + A07 +A08= X
+ + + +
A09 + A10 + A11 + A12= X
+ + + +
A13 + A14 + A15 + A16= X
= = = =X X X X
And:
A1+A6+A11+A16=X
A4+A7+A10+A13=X
private: // User declarations
int **Table;
int value;
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
value=StrToInt(Edit1->Text);
int temp,i,j;
temp=value-20;
Table[0][0]=temp;
Table[2][1]=temp-1;
Table[3][2]=temp+2;
Table[1][3]=temp+1;
Table[1][0]=1;
Table[3][0]=7;
Table[1][1]=8;
Table[3][1]=2;
Table[0][2]=5;
Table[2][2]=3;
Table[0][3]=4;
Table[2][3]=6;
Table[3][3]=9;
Table[1][2]=10;
Table[0][1]=11;
Table[2][0]=12;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
StringGrid1->Cells[i][j]=IntToStr(Table[i][j]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
int i;
Table=new int *[4];
for(i=0;i<4;i++)
Table[i]=new int[4];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
int i;
for(i=0;i<4;i++)
delete [] Table[i];
delete [] *Table;
}
Brak komentarzy:
Prześlij komentarz