Abdullayev Muhammadamin SWD001
2-Amaliy mashg’ulot
Mavzu: QIDIRISH VA SARALASH ALGORITMLARI
To’g’ridan-to’g’ri qo’shish usuli bilan saralash algoritmi(insertion sort)
Tanlash orqali saralash algoritmi (Selection sort)
Pufaksimon saralash algoritmi (Bubble sort)
Chiziqli qidirish(linear search)
Binar qidirish(binary search)
.
VARIANT-N1
A massivning elementlarini to’g’ridan-to’g’ri qo’shish usuli bilan saralash algoritmidan foydalanib saralang va massivning eng katta elementini ekranga chiqarish dasturini tuzing
DASTUR KODI
#include
using namespace std;
int main()
{ int k, n=10,min;
int A[n]={4,2,8,0,5,3,9,1,7,6};
for(int i=0;imin=i;
for(int j=i+1;jif (A[j]}
if (min!=i) swap(A[i],A[min]);
}
cout<<"Massivning eng katta elementi="<return 0;
}
Do'stlaringiz bilan baham: |