Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- int n,
- c[255],
- i,
- pom;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::btnZadanieClick(TObject *Sender)
- {
- n = StrToInt(InputBox("Kolko cisiel chcete zadat?","Cislo","0"));
- lblZadane->Caption="";
- for (i = 0; i < n; i++) {
- c[i] = StrToInt(InputBox("Zadajte "+IntToStr(i+1)+". cislo","Cislo","0"));
- if ( i == n ) {
- lblZadane->Caption=lblZadane->Caption+StrToInt(c[i]);
- } else {
- lblZadane->Caption=lblZadane->Caption+StrToInt(c[i])+" ";
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::btnZoradenieClick(TObject *Sender)
- {
- i = 0;
- lblZoradene->Caption = "";
- while ( i!=n ) {
- if ( c[i] > c[i+1] ) {
- pom = c[i];
- c[i] = c[i+1];
- c[i+1] = pom;
- i = 0;
- } else i++;
- }
- for (i = 1; i <= n; i++) {
- if ( i == n ) {
- lblZoradene->Caption=lblZoradene->Caption+StrToInt(c[i]);
- } else {
- lblZoradene->Caption=lblZoradene->Caption+StrToInt(c[i])+" ";
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::btnGenClick(TObject *Sender)
- {
- int s[10];
- Label1->Caption="";
- Label2->Caption="";
- for (i = 0; i < 10; i++) {
- s[i] = random(100)+1;
- Label2->Caption=Label2->Caption+IntToStr(s[i])+" ";
- }
- i = 0;
- while (i<10) {
- if ( s[i] > s[i+1] ) {
- pom = s[i];
- s[i] = s[i+1];
- s[i+1] = pom;
- i=0;
- } else i++;
- }
- for (i = 0; i < 10; i++) {
- Label1->Caption=Label1->Caption+IntToStr(s[i])+" ";
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment