|
Mashqlarbajarish uchun variantlarBog'liq амалий iIAKT (2)Mashqlarbajarish uchun variantlar:
1.
Koordinata o„qida X va Y nuqtalarining shtrixlangan maydonga
tegishli ekanligini aniqlang.
2.
Berilgan X,Y,Z sonlarining minimal va maksimal qiymatlarining
yig„indisini topish dasturi tuzilsin.
3.
Yil oylarining tartib raqamiga asosan oy nomlarini bosmaga bosib
chiqarish dasturi tuzilsin. Misol uchun, 3 sonini kiritsak «Mart» so„zi chiqsin.
Quyidagi misolni visual rejim ko„rinishida ishlab ko„ramiz.
1-mashq.
№ Misolning berilishi
Berilgan qiymatlar
1
2
y
3x - 3abx agar a
0
13a - b
2
x agar a
0
x=2,7
b=3,2
a=1,(-
1)
Formaning ko„rinishini shakllantiramiz. Formada quyidagi komponentalarni
o„rnatamiz: 4 ta Label, 3ta Edit va 2 ta Button (Natija va chiqish). Formaga
TRadioCroup1 komponentasini joylashtirib, Object inspectordan Items xossasini
o„rnatib, qator uchun shartni o„rnatamiz (23- rasm).
23-rasm. Formaning ko„rinishi
Unit1.h fayl oynasida tanlangan komponentalar quyidagi
ko„rinishda bo„ladi: #ifndef Unit1H
#define Unit1H
//
#include
#include
#include
#include
//
class TForm1 : public TForm
{
published: // IDE-managed
Components TLabel *Label1;
TLabel
*Label2;
TLabel
*Label3;
TLabel
*Label4; TEdit
*Edit1; TEdit
*Edit2; TEdit
*Edit3; TButton
*Button1;
TRadioGroup
*RadioGroup1; TButton
*Button2;
void fastcall Button1Click(TObject
*Sender); void fastcall
Button2Click(TObject *Sender);
private: // User declarations
public:
// User
declarations
fastcall TForm1(TComponent* Owner);
};
//
extern PACKAGE TForm1 *Form1;
//
#endif
Dastur kodi:
//
#include
#pragma hdrstop
#include "Unit1.h"
//
#pragma package(smart_init)
#pragma resource
"*.dfm" TForm1
*Form1;
//
fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//
void fastcall TForm1::Button1Click(TObject
*Sender)
{ float a,b,x,y;
a=StrToFloat(Edit1-
>Text);
b=StrToFloat(Edit2-
>Text);
x=StrToFloat(Edit3-
>Text);
if(a>0) { y=3*x*x-3*a*b*x; RadioGroup1-
>ItemIndex=0; Label4-
>Caption="y="+FloatToStr(y);};
else {y=13*a-b*b*x; RadioGroup1-
>ItemIndex=1; Label4-
>Caption="y="+FloatToStr(y);}
}
//
void fastcall TForm1::Button2Click(TObject
*Sender)
{ Close(); }
//
|
| |