Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <stdlib.h>
- #include <time.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- srand(time(NULL));
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- try
- {
- int min, max;
- min = StrToInt(editMin->Text);
- max = StrToInt(editMax->Text);
- if(min > max)
- throw -1;
- int matice[10][10];
- int soucet = 0;
- for(int i = 0; i < 10; i++)
- {
- for(int j = 0; j < 10; j++)
- {
- matice[i][j] = rand()%(max-min+1)+min;
- soucet += matice[i][j];
- }
- }
- AnsiString radek = "";
- for(int r = 0; r < 10; r++)
- {
- for(int s = 0; s < 10; s++)
- {
- radek += " ";
- radek += IntToStr(matice[r][s]);
- }
- Memo1->Lines->Add(radek);
- radek = "";
- }
- radek = "";
- Memo1->Lines->Add(radek);
- radek = "Součet: " + IntToStr(soucet);
- Memo1->Lines->Add(radek);
- Memo1->Lines->
- }
- catch(int x)
- {
- ShowMessage("Špatné hranice intervalu");
- }
- catch(...)
- {
- ShowMessage("Není číslo");
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement