GamerSK

Untitled

Jan 20th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 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. float TForm1::diskriminant(int a, int b, int c) {
  17.     return b*b - 4*a*c;
  18. }
  19. float TForm1::priemerz2(int a, int b) {
  20.     return (a+b)/2.00;
  21. }
  22. int TForm1::sucetn(int n) {
  23.     int s = 0;
  24.     for (int i = 0; i < n; i++) {
  25.         s += StrToInt(
  26.             InputBox("Zadajte cislo", "cislo", "")
  27.         );
  28.     }
  29.     return s;
  30. }
  31. int TForm1::max(int n) {
  32.     int max = 0;
  33.     int c = 0;
  34.     for (int i = 0; i < n; i++) {
  35.         c = StrToInt(
  36.             InputBox("Zadajte cislo", "cislo", "")
  37.         );
  38.         if ( c > max ) {
  39.             max = c;
  40.         }
  41.     }
  42.     return max;
  43. }
  44. int TForm1::min(int n) {
  45.     int min = 19999999999;
  46.     int c = 0;
  47.     for (int i = 0; i < n; i++) {
  48.         c = StrToInt(
  49.             InputBox("Zadajte cislo", "cislo", "")
  50.         );
  51.         if ( c < min ) {
  52.             min = c;
  53.         }
  54.     }
  55.     return min;
  56. }
  57. int TForm1::mocnina(int m, int n) {
  58.     int o = m;
  59.     for (int i = 0; i < n-1; i++) {
  60.         o *= m;
  61.     }
  62.     return o;
  63. }
  64. int TForm1::factorial(int c) {
  65.     int s = 1;
  66.     for (int i = 1; i <= c; i++) {
  67.         s *= i;
  68.     }
  69.     return s;
  70. }
  71. int TForm1::sucetcifra(AnsiString str) {
  72.     int s = 0;
  73.     for (int i = 1; i <= str.Length(); i++) {
  74.         s += StrToInt(str[i]);
  75.     }
  76.     return s;
  77. }
  78. int TForm1::pocetznakov(char z, AnsiString str) {
  79.     int p = 0;
  80.     for (int i = 1; i <= str.Length(); i++) {
  81.         if ( str[i] == z ) {
  82.             p++;
  83.         }
  84.     }
  85.     return p;
  86. }
  87. AnsiString TForm1::zrkadlo(AnsiString str) {
  88.     AnsiString o = "";
  89.     for (int i = str.Length(); i >= 1; i--) {
  90.         o += str[i];
  91.     }
  92.     return o;
  93. }
  94. void TForm1::vystup(AnsiString v) {
  95.     ShowMessage(v);
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TForm1::Button1Click(TObject *Sender)
  99. {
  100.     int a = StrToInt(InputBox("", "", ""));
  101.     int b = StrToInt(InputBox("", "", ""));
  102.     int c = StrToInt(InputBox("", "", ""));
  103.     vystup(AnsiString(diskriminant(a, b, c)));
  104. }
  105. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment