GamerSK

testovanie 9

Oct 5th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.44 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. //---------------------------------------------------------------------------
  12. __fastcall TForm1::TForm1(TComponent* Owner)
  13.     : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::btnSucetClick(TObject *Sender)
  18. {
  19.     int c,
  20.         s = 0,
  21.         n = StrToInt(InputBox("Zadajte pocet opakovani","Cislo","0"));
  22.     for (int i = 1; i <= n; i++) {
  23.         c = StrToInt(InputBox("Zadajte cislo","Cislo","0"));
  24.         s += c;
  25.     }
  26.     ShowMessage(IntToStr(s));
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::btnMinClick(TObject *Sender)
  30. {
  31.     int c,
  32.         s = 0,
  33.         min = 9999999999999999,
  34.         n = StrToInt(InputBox("Zadajte pocet opakovani","Cislo","0"));
  35.     for (int i = 1; i <= n; i++) {
  36.         c = StrToInt(InputBox("Zadajte cislo","Cislo","0"));
  37.         if ( c < min ) {
  38.             min = c;
  39.         }
  40.     }
  41.     ShowMessage(IntToStr(min));
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TForm1::btnUmocClick(TObject *Sender)
  45. {
  46.     int x = StrToInt(InputBox("Zadajte cislo, ktore chcete umocnit","Cislo","0")),
  47.         m = StrToInt(InputBox("Zadajte mocnitela","Cislo","0")),
  48.         v = 1;
  49.     for (int i = 1; i <= m; i++) {
  50.         v = v * x;
  51.     }
  52.     ShowMessage(IntToStr(v));
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TForm1::btnPrestClick(TObject *Sender)
  56. {
  57.     int rok = StrToInt(InputBox("Zadajte rok","Rok","2018"));
  58.     if ( rok % 4 == 0) {
  59.         ShowMessage("Rok "+IntToStr(rok)+" je prestupny");
  60.     } else {
  61.         ShowMessage("Rok "+IntToStr(rok)+" nieje prestupny");
  62.     }
  63. }
  64. //---------------------------------------------------------------------------
  65. void __fastcall TForm1::btnZnamClick(TObject *Sender)
  66. {
  67.     int z = StrToInt(InputBox("Zadajte znamku","Znamka","1"));
  68.     switch ( z ) {
  69.  
  70.         case 1 :
  71.             ShowMessage("Velmi vyborne");
  72.             break;
  73.         case 2 :
  74.             ShowMessage("Vyborne");
  75.             break;
  76.         case 3 :
  77.             ShowMessage("Dobre");
  78.             break;
  79.         case 4 :
  80.             ShowMessage("Zle");
  81.             break;
  82.         case 5 :
  83.             ShowMessage("Velmi zle");
  84.             break;
  85.    
  86.     }
  87. }
  88. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment