Tajriba ishini bajarish uchun topshiriq variantlari:
1. t=
bunda x=14.26, y=-1.22, z=3.5x10 t=0.564849.
2. u=
bunda x=-4.5, y=0.75x10 , z=0.845x10 , u=-55,6848 .
3. v= x +cos (arctg ),
bunda x=3.74*10 , y=-0.825, z=0.16*10 , v=1.0553.
4. w=
bunda x=4000, y=-0.875, z=-0.000475, w=1.9873.
5. y )((x-y/2)+sin arctg(z),
bunda x=-15.246, y=0.04642, z=2000.1 =-182.036.
6.
bunda x=16.55*10 , y=-2.75, z=0.15
7. a=5arctg(x)- ,
bunda x=0.1722, y=6.33, z=3.25*10 a=-172.025.
8.
bunda x=-2.235*10 , y=2.23, z=15.221 .
9. ,
bunda x=1.825*10 , y=18.225, z=-3.298*10
10. q=2 ,
bunda x=3,981*10 , y=-1.625*10 , z=0.512 q=1.26185 .
1.
2.
3.
4.
5.
№
|
xn
|
xk
|
S(x)
|
h
|
Y(x)
|
1
|
2
|
3
|
4
|
5
|
6
|
1
|
0.1
|
1
|
|
0.1
|
|
2
|
0.1
|
1
|
|
0.1
|
|
3
|
0.1
|
1
|
|
0.1
|
|
4
|
0.1
|
1
|
|
0.1
|
|
5
|
0.1
|
1
|
|
0.1
|
|
6
|
0.1
|
1
|
|
0.1
|
|
7
|
0.1
|
1
|
|
0.1
|
|
8
|
0.1
|
1
|
|
0.1
|
|
9
|
0.1
|
1
|
|
0.1
|
|
10
|
0.1
|
0.5
|
|
0.1
|
|
12-LABORATORIYA ISHI
Aviasozlik soxasidagi masalalarni dasturlashtirishda ko’p o’lchovli massivlardan foydalanish.
Ishdаn mаqsаd: Ма’lumоtlаrning struktura (struktura) tоifаsidаgi bеrilgаnlаrini xotiragа kiritish vа xotiradаn chiqаrishni tаshkil qilishni, yozuvlаr qаtnаshgаn mаsаlаlаrning yechish dаsturini tuzishni o‘rgаnish.
Tоpshiriqlаr:
Struktura tоifаdаgi mа’lumоtlаr-yozuvlаr vа ulаr bilаn ishlаsh qismini o‘qing.
Маsаlаning yechish dаsturini yozing vа uni kompyuterda bаjаring.
Bаjаrilgаn ish bo‘yichа hisоbоt tаyyorlаng.
Nаzаriy qism
Ba‘zi masalalarda berilgan kattalik turli toifadagi ma‘lumotlardan tashkil topgan ob’ektni ifodalaydi, masalan, talaba kattaligi talaba familiyasi, guruh nomeri, tugilgan sana va adresini o‘z ichiga oladi. Bunday kattaliklar bilan dastur tuzishda C++ tilidа struktura tоifаsi belgilangаn. Faqat bir hil toifadagi elementlardan tashkil topishi mumkin bo‘lgan massivdan farqli struktura turli hil toifadagi elementlardan iborat bo‘lishi mumkin.
Struktura quyidagicha e’lon qilinadi:
struct [tur nomi]
{1-toifa nomi 1-элемент;
2-toifa moni 2-элемент;
n-toifa nomi n- элемент_;}
[ta‘riflovchilar ro‘yxati] [ список_описателей ];
Misol:
struct Ishchi
{ // Ishchi nomli yangi turni e’lon qilish
char fio[30];
int date, code;
float salary; };
Ishchi stuff[100];/* Worker toifasidagi massivni aniqlash */
Bu misolda yangi toifa yaratildi. Uning nomini standart toifalar bilan ishlatish imkoni paydo bo‘ldi.
Strukturani o‘zgaruvchilarni tavsiflash ro‘yxatini berish orqali ham e’lon qilish mumkin
struct
{
char fio[30];
int date, code;
float salary; } stuff[100; /* stuff struktura toifasidagi massiv */
Struktura elementlariga murojaat struktura nomi orqali amalga oshiriladi:
Ishchi, stuff[100], *ps;
...
Ishchi.fio = "Страусенко";
stuff[8].code = 215;
ps->salary = 0.12;
Bir variantning echimi
1-masala. Berilgan massivda kitoblar haqida ma‘lumotlar berilgan. Xar bir kitob to‘g‘risida: - kitobning nomi, muallifning ism-sharifi, kitob bosilgan sanasi. Shunday dastur tuzish kerakki, unda kitob chiqqan sanasi 2008yilga teng yoki 2008 yildan katta bo‘lsin va bu kitoblar soni aniqlansin.
//--------------------------------------------------------------------
#include
#include
#include
#pragma hdrstop
//--------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{ typedef struct {
char title[40];
char author[20];
int entry; }book ;
int sum=0;
book k;
book b[10];
int i;
for (i=1;i<=5; i++)
{ cout<<"naimenovanie knigi"<
cin>>b[i].title;
cout<<"avtor"<
cin>>b[i].author;
cout<<"god izdanie"<
cin>>b[i].entry;
}
for (i=1; i<=5; i++)
if (b[i].entry<=2008) sum=sum+1;
cout<<"Summa knig sum="<
getch();
return 0;
}
//-------------------------------------------------------------------
2-masala. Talabalarning familiyasi va ta‘lim olayotgan bosqichi haqida ma‘lumotlar berilgan. Bu ma‘lumotlar asosida 2-bosqich talabalari ro‘yhatini chiqaring.
Boshlang‘ich Forma ko‘rinishini quyidagicha yaratamiz(8-rasm):
Forma ko‘rinishi
Dastur kodi:
//-------------------------------------------------------------
#include
#include
#include
#include
#pragma hdrstop
#include "Unit1.h"
//----------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma argsused
TForm1 *Form1;
typedef struct {
String fam;
int kurs; }book ;
book a[10]; int n;
//---------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//-----------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{ n=n+1;
a[n].fam=Edit1->Text;
a[n].kurs=StrToInt(Edit2->Text);
Edit1->Text="";
Edit2->Text="" ; }
//-----------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{ int i;
for (i=1;i<=2; i++)
{
Memo1->Lines->Add(a[i].fam);
Memo1->Lines->Add(IntToStr(a[i].kurs));
} }
//-------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{ int i;
for (i=1;i<=2; i++)
{ if (a[i].kurs==2){
Memo2->Lines->Add(a[i].fam);
Memo2->Lines->Add(IntToStr(a[i].kurs));}
} }
//----------------------------------------------------------------
Dastur bajarilishi natijasida quyidagi Forma chiqadi va Memo2 komponentasida asosiy natija olinadi(9-rasm):
Forma ilovasida olingan natijalar
Do'stlaringiz bilan baham: |