//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; float f1[14]; float f2[14]; float f3[14]; float f4[14]; int A; float f12(int A) {float max=0; for(int x=0;x<=A;x++) if ((f1[x]+f2[A-x])>=max) max=f1[x]+f2[A-x]; return max;} //-------------------------------------- float f123(int A) {float max=0; for(int x=0;x<=A;x++) if ((f12(x)+f3[A-x])>=max) max=f12(x)+f3[A-x]; return max;} //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::BitBtn1Click(TObject *Sender) { tMoney->Insert(); // Добавление записи //Заненсение данных tMoney->FieldByName("Nomer")->AsString = leNomer->Text; tMoney->FieldByName("1 Zona")->AsString = leZona1->Text; tMoney->FieldByName("2 Zona")->AsString = leZona2->Text; tMoney->FieldByName("3 Zona")->AsString = leZona3->Text; tMoney->FieldByName("4 Zona")->AsString = leZona4->Text; tMoney->Post(); // Сохрнение записи в таблице } //--------------------------------------------------------------------------- //--------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { tMoney->Open(); } //--------------------------------------------------------------------------- void __fastcall TForm1::BitBtn2Click(TObject *Sender) { if (pMoney) { for (int i = 0; i < Tag; i++) delete[] pMoney[i]; // STEP 1: DELETE THE COLUMNS delete[] pMoney; } pMoney = new float *[tMoney->RecordCount]; Tag = tMoney->RecordCount; for (int i = 0; i < tMoney->RecordCount; i++) pMoney[i] = new float[5]; tMoney->First(); for (int i=0; i< tMoney->RecordCount; i++) { for (int j = 0; j < 5; j++) { pMoney[i][j] = tMoney->Fields->Fields[j]->AsFloat; } tMoney->Next(); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { sgMassiv->ColCount = 5; sgMassiv->RowCount = Tag; for(int i=0; iCells[j][i] = FloatToStr(pMoney[i][j]); } // ----------------------------------- ---------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) {int j = 0; sgMassiv->RowCount = Tag; for(int i=0; iText); double max=0; for(int x=0;x<=A;x++) {if ((f123(x)+f4[A-x])>=max) {max=f123(x)+f4[A-x];u4=x; U4=A-x;}} LabeledEdit1->Text=max; max=0; Edit1->Text=U4; //Kopi for(int x=0;x<=u4;x++) {if ((f12(x)+f3[u4-x])>=max) {max=f12(x)+f3[u4-x];u3=x;U3=u4-x;}} max=0; Edit2->Text=U3; //Kopi for(int x=0;x<=u3;x++) {if ((f1[x]+f2[u3-x])>=max) {max=f1[x]+f2[u3-x];u1=x;u2=u3-x;}} Edit3->Text=u2;Edit4->Text=u1; } //---------------------------------------------------------------------------