//---------------------------------------------------------------------------
template <class Type> Type summa (Type* mas)
{
Type s=0;
for (int i=0;i<9;i++)
{
if (mas [i]>0)
s+=mas[i];
}
return s;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N1Click(TObject *Sender)
{
randomize;
for (int i=0;i<10;i++)
{
StringGrid1->Cells[i][0]=IntToStr(random(20)-10);
StringGrid2->Cells[i][0]=FloatToStr((random(100)-50)*0.01);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N2Click(TObject *Sender)
{
int a[10], x;
double b[10], y;
for (int i=0;i<10;i++)
{
a[i]=StrToInt(StringGrid1->Cells[i][0]);
b[i]=StrToFloat(StringGrid2->Cells[i][0]);
}
x=summa(a);
y=summa(b);
for (int i=0;i<10;i++)
{
Edit1->Text=IntToStr(x);
Edit2->Text=FloatToStr(y);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
randomize;
for(int i=0;i<5;i++)
for(int j=0;j<5;j++)
{
StringGrid1->Cells[i][j]=IntToStr(random(20)-10);
StringGrid2->Cells[i][j]=IntToStr(random(20)-10);
}
}
int col (int* mas)
{
int k=0;
int s;
for(int i=0;i<5;i++)
{
s=0;
for(int j=0;j<5;j++)
{
s=s+mas[i*5+j];
}
if (s>0) k++;
}
return k;
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int a[5][5], b[5][5];
for(int i=0;i<5;i++)
for(int j=0;j<5;j++)
{
a[j][i]=StrToInt(StringGrid1->Cells[i][j]);
b[j][i]=StrToInt(StringGrid2->Cells[i][j]);
}
Edit1->Text=IntToStr(col(&a[0][0]));
Edit2->Text=IntToStr(col(&b[0][0]));
}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.