Advertisement
sMteX

Matice Memo Bety

Jan 2nd, 2016
70
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 <stdlib.h>
  5. #include <time.h>
  6.  
  7. #pragma hdrstop
  8.  
  9. #include "Unit1.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma resource "*.dfm"
  13. TForm1 *Form1;
  14. //---------------------------------------------------------------------------
  15. __fastcall TForm1::TForm1(TComponent* Owner)
  16.     : TForm(Owner)
  17. {
  18. srand(time(NULL));
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TForm1::Button1Click(TObject *Sender)
  22. {
  23. try
  24. {
  25.     int min, max;
  26.     min = StrToInt(editMin->Text);
  27.     max = StrToInt(editMax->Text);
  28.     if(min > max)
  29.        throw -1;
  30.     int matice[10][10];
  31.     int soucet = 0;
  32.     for(int i = 0; i < 10; i++)
  33.     {
  34.         for(int j = 0; j < 10; j++)
  35.         {
  36.             matice[i][j] = rand()%(max-min+1)+min;
  37.             soucet += matice[i][j];
  38.         }
  39.     }
  40.     AnsiString radek = "";
  41.     for(int r = 0; r < 10; r++)
  42.     {
  43.         for(int s = 0; s < 10; s++)
  44.         {
  45.         radek += "    ";
  46.             radek += IntToStr(matice[r][s]);
  47.         }
  48.         Memo1->Lines->Add(radek);
  49.         radek = "";
  50.     }
  51.     radek = "";
  52.         Memo1->Lines->Add(radek);
  53.     radek = "Součet: " + IntToStr(soucet);
  54.     Memo1->Lines->Add(radek);
  55.         Memo1->Lines->
  56. }
  57. catch(int x)
  58. {
  59.     ShowMessage("Špatné hranice intervalu");
  60. }
  61. catch(...)
  62. {
  63.     ShowMessage("Není číslo");
  64. }
  65. }
  66. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement