Muhammadsoliyev Izzatullaxo`ja


Download 38.08 Kb.
Sana16.06.2023
Hajmi38.08 Kb.
#1506182
Bog'liq
Muhammadsoliyev 1-5 amaliy ishlar


F.I.Sh

Guruh

Fan

Tekshirdi

Muhammadsoliyev Izzatullaxo`ja

680-21

Algoritmlarni loyihalash

R.Nabijonov

1-amaliy ish.



  1. Uchburchakning tomonlari 7, 8 va 9 ga teng. Shuuchburchakning yuzini toping.

#include


#include
using namespace std;

int main()


{ float a, b, c, p, S;
cout <<"a="; cin >>a ;
cout <<"b="; cin >>b ;
cout <<"c="; cin >>c ;
p=(a+b+c)/2;
cout<<"Yarim perimetr="<
S=sqrt(p*(p-a)*(p-b)*(p-c));

cout<<"Uchburchakning yuzi="<
return 0;
}






F.I.Sh

Guruh

Fan

Tekshirdi

Muhammadsoliyev Izzatullaxo`ja

680-21

Algoritmlarni loyihalash

R.Nabijonov

2-amaliy ish.
2x4 matritsa hosil qiling va indekslari (i,j) teng bo’lgan qiymatlarini yig’indisini ekranga chiqaring.
#include
#include
using namespace std;

int main()


{ int i,j,N,M,a[20][20];

cout<<"N=";


cin>>N;

cout<<"M=";

cin>>M;

cout<<"Input matrix A \n";

for (i=0; i

for (j=0; j

cin>>a[i][j];


cout<<"matrix A \n"; for (i=0; i

{for (j=0; j

cout<

cout<
}

return 0;


}


F.I.Sh

Guruh

Fan

Tekshirdi

Muhammadsoliyev Izzatullaxo`ja

680-21

Algoritmlarni loyihalash

R.Nabijonov

3-amaliy ish.

  1. 1. Butun sonlar orqali berilgan 100 dan 200 gacha bo’lganlari ichida ekranga 150 raqami chiquvchi chiziqli qidiruv algoritmi tuzilsin va natijalar taxlil qilinsin.

#include


using namespace std;


int chiziqli_qidiruv(int array[], int size, int searchValue)
{ for(int i =0; i < size; i++)
{ if(searchValue == array[i]) {
return i;
}} return-1;}
int main()
{
int a[]={100,110,120,130,140,150,160,170,180,190,200};
int qid_son;
cout<<"Qidirilayotgan sonni kiriting: "<<" ";
cin>>qid_son;
int natija = chiziqli_qidiruv(a, sizeof(a), qid_son);
if(natija >=0)
{ cout<<"Qidirilayotgan son "<< a[natija]<<" "<< natija <<"- indexda joylashgan"<< endl;
}
else
{ cout<<"Qidirilayotgan son "<< qid_son <<" ushbu massivda mavjud emas. "<< endl;
}}





F.I.Sh

Guruh

Fan

Tekshirdi

Muhammadsoliyev Izzatullaxo`ja

680-21

Algoritmlarni loyihalash

R.Nabijonov

4-amaliy ish.

“28”, “12”, “11”, “32”, “0”, “53”, “84”, “45”, “59” berilgan butun sonlarni ixtiyoriy saralash usuli orqali dasturi ishlab chiqilsin va taxlil qilinsin.


#include
#include
using namespace std;

int main()


{
int a[9]={28,12,11,32,0,53,84,45,59};
for (int i=1;i<5;i++)
{ for (int j=0;j<5-i;j++)
{ if (a[j]>a[j+1])
swap(a[j],a[j+1]); } }
for (int i=0;i<5;i++)
cout< cout<

return 0;


}




F.I.Sh

Guruh

Fan

Tekshirdi

Muhammadsoliyev Izzatullaxo`ja

680-21

Algoritmlarni loyihalash

R.Nabijonov

5-amaliy ish.
Topshiriq
1.Ism Familyangizdagi elementlarni saralang va binarqidiruv algoritmidan foydalanib ixtiyoriy elementni joylashgan indeksini toping.
1.sort()
2.qidiruv(binary)
Misol uchun: nabijonovravshanbek

#include
using namespace std;
int binarqidiruv(char a[],int b, int o, char x){
if(o>=b)
{int mid=b+(o-b)/2;
if(a[mid]==x)
return mid;
if(a[mid]>x)
return binarqidiruv(a, b, mid-1, x);
return binarqidiruv(a, mid+1, o, x);
} return -1;
}
int main()
{ int n;
cout<<"sonini kiriting: ";
cin>>n;
char a[n];
cout<<"Elementlarni kiriting: ";
for(int i=0; icin>>a[i];
for(int i=n-1; i>=1; i--)
{ for(int j=0; j{if(a[j]>a[j+1])
{ swap(a[j],a[j+1]);
}}}
for(int i=0; icout<cout<char x;
cout<<"Qidirilayotgan elementni kiriting: ";
cin>>x;
int natija=binarqidiruv(a,0,n-1, x);
cout<<"Qidirilayotgan element "<return 0;
}

Download 38.08 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling