Advertisement
Guest User

Untitled

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