Добавил:
masterdos
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Т.С.П.П / Махинации с ТСПП / Махинации с ТСПП / ТПСПП_ира / gh3 / Unit1
.cpp//---------------------------------------------------------------------------
#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