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