Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <vector.h>
- #include <algorithm>
- #pragma hdrstop
- #include "Unit5.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- TGridRect a;
- SG1->Selection = a;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- SG1->ColCount = StrToInt(Edit1->Text);
- vector<int> ar(SG1->ColCount);
- ar.reserve(15);
- for(int i = 0; i <= SG1->ColCount; i++)
- {
- ar.push_back(random(20)-10);
- SG1->Cells[i][0] = ar[i-1];
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- vector<int>::const_iterator minimal = min_element(ar.begin(), ar.end());
- int s = 0;
- for (int i = *minimal + 1; i <= SG1->ColCount; i++, s += ar[i]);
- Label1->Caption = IntToStr(s);
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement