niedziela, 22 stycznia 2017

Creating a number of cells StringGrids (C++ Builder)


private: // User declarations
void __fastcall init_Random();
int *first_v, *tenth_v, *hundreth_v, *thausend_v,*new_values;
void __fastcall create_Values();
void __fastcall write_Values();

void __fastcall TForm1::init_Random()
{
srand(time(NULL));
}
void __fastcall TForm1::create_Values()
{
int i,j;
first_v=new int[1000];
tenth_v=new int[1000];
hundreth_v=new int[1000];
thausend_v=new int[1000];
    new_values=new int[1000];
for(i=0;i<100;i++)
{
first_v[i]=rand()%10;
tenth_v[i]=rand()%10;
hundreth_v[i]=rand()%10;
thausend_v[i]=rand()%10;
new_values[i]=(1000*thausend_v[i])+(100*hundreth_v[i])+
(10*tenth_v[i])+first_v[i];

}
}
void __fastcall TForm1::write_Values()
{
int i,j,k;
k=0;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
StringGrid1->Cells[j][i]=IntToStr(thausend_v[k]);
StringGrid2->Cells[j][i]=IntToStr(hundreth_v[k]);
StringGrid3->Cells[j][i]=IntToStr(tenth_v[k]);
StringGrid4->Cells[j][i]=IntToStr(first_v[k]);
ListBox1->Items->Add(IntToStr(k+1)+" )  - "+IntToStr(new_values[k]));
k++;
}
}
}


void __fastcall TForm1::FormCreate(TObject *Sender)
{
 init_Random();
 create_Values();
 write_Values();
}
//---------------------------------------------------------------------------



void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
 delete thausend_v;
 delete hundreth_v;
 delete tenth_v;
 delete first_v;
 delete new_values;
}

Brak komentarzy:

Prześlij komentarz