void __fastcall TMainForm::RBtn3Click(TObject *Sender)
{
SEdit2->Text=IntToStr(1);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::RBtn4Click(TObject *Sender)
void __fastcall TMainForm::Btn1Click(TObject *Sender)
Application->Terminate();
void __fastcall TMainForm::Btn2Click(TObject *Sender)
Analisation ob,ob1;
matrix first (n,m);
matrix second (k,l);
first.Read(sg1,ob);
second.Read(sg2,ob1);
matrix res=Transposing(first);
Resform->sg3->RowCount=res.Getx();
Resform->sg3->ColCount=res.Gety();
for(int i=0; i<res.Getx(); i++)
for (int j=0; j<res.Gety(); j++)
res.matr[i][j].videlen();
for (int i=0; i<res.Getx(); i++)
Resform->sg3->Cells[j][i]=IntToStr(res.matr[i][j].cel)+
"*"+IntToStr(res.matr[i][j].chisl)+
"/"+IntToStr(res.matr[i][j].znamen);
Resform->Box1->Visible=true;
Resform->ShowModal();
if (Resform->Box1->Checked)
matrix res1=Transposing (second);
Resform->sg3->RowCount=res1.Getx();
Resform->sg3->ColCount=res1.Gety();
for(int i=0; i<res1.Getx(); i++)
for (int j=0; j<res1.Gety(); j++)
res1.matr[i][j].videlen();
for (int i=0; i<res1.Getx(); i++)
Resform->sg3->Cells[j][i]=IntToStr(res1.matr[i][j].cel)+
"*"+IntToStr(res1.matr[i][j].chisl)+
"/"+IntToStr(res1.matr[i][j].znamen);
Resform->Box1->Visible=false;
void __fastcall TMainForm::Btn3Click(TObject *Sender)
if (first.Getx()==second.Getx() &&
first.Gety()==second.Gety())
matrix res=first+second;
Resform->sg3->Cells[j][i]="";
Resform->sg3->Cells[j][i]=IntToStr(res.matr[i][j].cel)+"*"+
IntToStr(res.matr[i][j].chisl)+
else MessageBox (NULL,"Ну кто так складывает","ЧАЙНИК!!",MB_ICONEXCLAMATION );
void __fastcall TMainForm::C1Click(TObject *Sender)
for (int i=0; i<sg1->RowCount; i++)
for (int j=0; j<sg1->ColCount; j++)
sg1->Cells[j][i]=IntToStr(1+random(6))+
"/"+IntToStr(1+random(6));
void __fastcall TMainForm::C2Click(TObject *Sender)
for (int i=0; i<sg2->RowCount; i++)
for (int j=0; j<sg2->ColCount; j++)
sg2->Cells[j][i]=IntToStr(1+random(6))+
void __fastcall TMainForm::Btn4Click(TObject *Sender)
matrix res=first-second;
else MessageBox (NULL,"Ну кто так отнимает","ЧАЙНИК!!",MB_ICONEXCLAMATION );
void __fastcall TMainForm::N1Click(TObject *Sender)
sg1->Cells[j][i]="";
Panel1->Caption="";
void __fastcall TMainForm::N2Click(TObject *Sender)
sg2->Cells[j][i]="";
Panel2->Caption="";
void __fastcall TMainForm::Btn5Click(TObject *Sender)
Nunit->ShowModal();
Analisation ob,ob1,ob2;
chislo=ob.MAIN(Nunit->Edit->Text.c_str());
first.Read(sg1,ob1);
second.Read(sg2,ob2);
matrix res1 (first.Getx(), first.Gety());
matrix res2 (second.Getx(), second.Gety());
if (Nunit->RBtn1->Checked)
res1=first.operator *(chislo);
"*"+IntToStr(res1.matr[i][j].chisl)+"/"+
IntToStr(res1.matr[i][j].znamen);
if (Nunit->RBtn2->Checked)
res1=first.operator *(Nunit->Edit->Text.ToInt());
res2=second.operator *(chislo);
for (int i=0; i<res2.Getx(); i++)
for (int j=0; j<res2.Gety(); j++)
res2.matr[i][j].videlen();
Resform->sg3->RowCount=res2.Getx();
Resform->sg3->ColCount=res2.Gety();
Resform->sg3->Cells[j][i]=IntToStr(res2.matr[i][j].cel)+
"*"+IntToStr(res2.matr[i][j].chisl)+"/"+
IntToStr(res2.matr[i][j].znamen);
res2=second.operator *(Nunit->Edit->Text.ToInt());
void __fastcall TMainForm::Btn6Click(TObject *Sender)
Analisation ob1,ob2;
drob temp1,temp2;
temp1=first.Determinant();
temp2=second.Determinant();
Panel1->Caption="Определитель первой: "+
IntToStr(temp1.cel)+"*"+IntToStr(temp1.chisl)+"/"
+IntToStr(temp1.znamen);
Panel2->Caption="Определитель второй: "+
IntToStr(temp2.cel)+"*"+IntToStr(temp2.chisl)+"/"
+IntToStr(temp2.znamen);
Пример использования данной программы:
Общий вид формы после запуска приложения (Рис. 1).
Рис.1
После определения размеров матриц, можно заполнить их вручную либо случайными числами, как показано на рисунке 2 и 3. Причём работать можно с дробными числами (вводить дроби и результат получать также дробный, прописано выделение целой части).
Рис.2 Рис.3
В данной программе предусмотрены такие действия над матрицами:
A. сложение;
B. вычитание;
C. транспонирование;
D. умножение на число;
E. вычисление простейших определителей;
Пример сложения двух матриц в данной программе продемонстрирован
на рис.4 и 5.
Рис.4
В случае, если вы попытаетесь сложить матрицы не одинаковых размеров, появится сообщение об ошибке;
Аналогично с разностью двух матриц.
Рис.5
Пример транспонирования матриц продемонстрирован на рис. 6
Рис.6
Рис.7
Пример вычисления простейших определителей продемонстрирован на рис 9.
Страницы: 1, 2, 3