Скачиваний:
0
Добавлен:
30.05.2020
Размер:
4.84 Кб
Скачать
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int summ(int);
float Plowa(int);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Edit1->Clear();
Edit2->Clear();
Edit3->Clear();
Edit4->Clear();
Edit5->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int p1, p2, p3;
p1=StrToInt(Edit1->Text);
p2=StrToInt(Edit2->Text);
p3=StrToInt(Edit3->Text);
int s1=summ(p1);
int s2=summ(p2);
int s3=summ(p3);
if(s1>s2)
   if(s1>s3) Label5->Caption="1";
      //s1 -- наибольшая
   else Label5->Caption="3";//s3 -- наибольшая
else if(s2>s3) Label5->Caption="2";
      //s2 -- наибольшая
   else Label5->Caption="3";//s3 -- наибольшая
}
//---------------------------------------------------------------------------
int summ(int p)//Функция
{
int s=0;
while(p!=0)
{
s+=p%10;
p/=10;
}
return s;
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1->Clear();
Edit2->Clear();
Edit3->Clear();
Label5->Caption="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int i, a[10], k=0;  // Декларація одновимірного масиву
//Заповнення масиву А елементами з таблиці StringGrid1
        for(i=0; i<10;i++)
              a[i]=StrToInt(StringGrid1 ->Cells[i][0]);

        for(i=0; i<10;i++){
        if (a[i]==2) k++;
        else
        if (a[i]==3) k++;
        else
        if(a[i]==5) k++;
        else
        if (a[i]%2!=0 && a[i]%5!=0 && a[i]%3!=0)  k++;
        else k=k+0;
        }
        Label8->Caption=IntToStr(k);

}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{

int i;
for(i=0; i<10;i++)
StringGrid1 ->Cells[i][0]="";
Label8->Caption="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
int r, R;
float pl;
R=StrToFloat(Edit4->Text);
r=StrToFloat(Edit5->Text);
pl=Plowa(R)-Plowa(r);//Вызов
Label11->Caption="Площа кільця="+FloatToStrF(pl,ffFixed,5,3);
}
//---------------------------------------------------------------------------
float Plowa(int r)//Функция
{
return 3.141592*r*r;
}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)
{
Edit4->Clear();
Edit5->Clear();
Label11->Caption="Площа кільця=";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
 if (IsCharAlpha(Key) || Key==',' || Key=='.' || Key=='-') Key=0;
if(Key==VK_RETURN) {Edit1->SetFocus(); return;}        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
{
 if (IsCharAlpha(Key) || Key==',' || Key=='.' || Key=='-') Key=0;
if(Key==VK_RETURN) {Edit2->SetFocus(); return;}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &Key)
{
 if (IsCharAlpha(Key) || Key==',' || Key=='.' || Key=='-') Key=0;
if(Key==VK_RETURN) {Edit3->SetFocus(); return;}        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit4KeyPress(TObject *Sender, char &Key)
{
 if (IsCharAlpha(Key) || Key==',' || Key=='.' || Key=='-') Key=0;
if(Key==VK_RETURN) {Edit4->SetFocus(); return;}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit5KeyPress(TObject *Sender, char &Key)
{
 if (IsCharAlpha(Key) || Key==',' || Key=='.' || Key=='-') Key=0;
if(Key==VK_RETURN) {Edit5->SetFocus(); return;}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::StringGrid1KeyPress(TObject *Sender, char &Key)
{
  if (IsCharAlpha(Key) || Key==',' || Key=='.' || Key=='-') Key=0;
if(Key==VK_RETURN) {StringGrid1->SetFocus(); return;}
}
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------

Соседние файлы в папке gh3
  • #
    30.05.2020422.98 Кб0Project1.obj
  • #
    30.05.2020876 б0Project1.res
  • #
    30.05.2020851.97 Кб0Project1.tds
  • #
    30.05.20203.7 Кб0Project1.~bpr
  • #
    30.05.20201.07 Кб0Project1.~cpp
  • #
    30.05.20204.84 Кб0Unit1.cpp
  • #
    30.05.202051 б0Unit1.ddp
  • #
    30.05.202010.43 Кб0Unit1.dfm
  • #
    30.05.20202.39 Кб0Unit1.h
  • #
    30.05.2020539.48 Кб0Unit1.obj
  • #
    30.05.20204.76 Кб0Unit1.~cpp