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;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- float TForm1::diskriminant(int a, int b, int c) {
- return b*b - 4*a*c;
- }
- float TForm1::priemerz2(int a, int b) {
- return (a+b)/2.00;
- }
- int TForm1::sucetn(int n) {
- int s = 0;
- for (int i = 0; i < n; i++) {
- s += StrToInt(
- InputBox("Zadajte cislo", "cislo", "")
- );
- }
- return s;
- }
- int TForm1::max(int n) {
- int max = 0;
- int c = 0;
- for (int i = 0; i < n; i++) {
- c = StrToInt(
- InputBox("Zadajte cislo", "cislo", "")
- );
- if ( c > max ) {
- max = c;
- }
- }
- return max;
- }
- int TForm1::min(int n) {
- int min = 19999999999;
- int c = 0;
- for (int i = 0; i < n; i++) {
- c = StrToInt(
- InputBox("Zadajte cislo", "cislo", "")
- );
- if ( c < min ) {
- min = c;
- }
- }
- return min;
- }
- int TForm1::mocnina(int m, int n) {
- int o = m;
- for (int i = 0; i < n-1; i++) {
- o *= m;
- }
- return o;
- }
- int TForm1::factorial(int c) {
- int s = 1;
- for (int i = 1; i <= c; i++) {
- s *= i;
- }
- return s;
- }
- int TForm1::sucetcifra(AnsiString str) {
- int s = 0;
- for (int i = 1; i <= str.Length(); i++) {
- s += StrToInt(str[i]);
- }
- return s;
- }
- int TForm1::pocetznakov(char z, AnsiString str) {
- int p = 0;
- for (int i = 1; i <= str.Length(); i++) {
- if ( str[i] == z ) {
- p++;
- }
- }
- return p;
- }
- AnsiString TForm1::zrkadlo(AnsiString str) {
- AnsiString o = "";
- for (int i = str.Length(); i >= 1; i--) {
- o += str[i];
- }
- return o;
- }
- void TForm1::vystup(AnsiString v) {
- ShowMessage(v);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- int a = StrToInt(InputBox("", "", ""));
- int b = StrToInt(InputBox("", "", ""));
- int c = StrToInt(InputBox("", "", ""));
- vystup(AnsiString(diskriminant(a, b, c)));
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment