Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #include <vector.h>
  5. #include <algorithm>
  6. #pragma hdrstop
  7.  
  8. #include "Unit5.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma resource "*.dfm"
  12. TForm1 *Form1;
  13. //---------------------------------------------------------------------------
  14. __fastcall TForm1::TForm1(TComponent* Owner)
  15.         : TForm(Owner)
  16. {
  17. }
  18. //---------------------------------------------------------------------------
  19.  
  20. void __fastcall TForm1::FormCreate(TObject *Sender)
  21. {
  22.         TGridRect a;
  23.         SG1->Selection = a;
  24. }
  25. //---------------------------------------------------------------------------
  26.  
  27. void __fastcall TForm1::Button1Click(TObject *Sender)
  28. {
  29.         SG1->ColCount = StrToInt(Edit1->Text);
  30.         vector<int> ar(SG1->ColCount);
  31.         ar.reserve(15);
  32.         for(int i = 0; i <= SG1->ColCount; i++)
  33.         {
  34.                 ar.push_back(random(20)-10);
  35.                 SG1->Cells[i][0] = ar[i-1];
  36.         }
  37. }
  38. //---------------------------------------------------------------------------
  39.  
  40.  
  41.  
  42. void __fastcall TForm1::Button2Click(TObject *Sender)
  43. {
  44.         vector<int>::const_iterator minimal = min_element(ar.begin(), ar.end());
  45.         int s = 0;
  46.         for (int i = *minimal + 1; i <= SG1->ColCount; i++, s += ar[i]);
  47.         Label1->Caption = IntToStr(s);
  48. }
  49. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement