1 laboratoriya ishi laboratoriya mavzusi Ma’lumotlarni saralash algoritmlarini tartibli statistikasi


Download 134.05 Kb.
Sana27.05.2020
Hajmi134.05 Kb.
#110546
Bog'liq
1-labaratoriya


1-

laboratoriya ishi



LABORATORIYA mavzusi


1. Ma’lumotlarni saralash algoritmlarini tartibli statistikasi.





Ish tartibi:

Ishdan maqsad

Ushbu laboratoriya ishining maqsadi talabalar saralash va qidirishning qanday usullari va algoritmlari mavjudligini, ularning samaradorliklarini baholashni o`rganishlari kerak. Shu asosda saralash va qidirish usullarini qiyosiy tahlil qilishlari va ularga oid dasturlar tuzishni o`zlashtirishlari kerak.



2-variant.Avtomobillarni ta`mirlash tartibi ishlab chiqilsin. Bu yerda ta`mir tugashi sanasi qaysi avtomobil uchun ertaroq bo`lsa, shunga birinchi navbatda xizmat ko`rsatiladi.

Dastur kodi:

include

using namespace std;

int i, j, count, key;

void BubbleSort(int A[], int N)

{

for (i=0; i

{

for (j=0; j

{

key=j+1;


count=A[key];

if (A[j]>A[key])

{

A[key]=A[j];



A[j]=count;

}}}


cout<<"saralangan sana: ";

for (i=0; i

int main()

{

setlocale(LC_ALL, "Rus");



int N; int A[1000];

cout<<"sanalar soni: > "; cin>>N;

for (i=0; i

{ cout< "; cin>>A[i]; }

BubbleSort(A, N);

system("pause>>void");



}
Dastur natijasi:





Boshlash




12,1,23,20,30



A[j]>A[key]



1,12,20,23,30




Tugatish

#include

using namespace std;
struct tal{
int yoshi;
string FIO;

double tugilgan_yili;

double bahosi;
};
int q=0;

void qs(tal *a,int first,int last){

int i = first, j = last;tal x =a[(first + last) / 2];
do {
while (a[i].yoshi < x.yoshi) i++;
while (a[j].yoshi > x.yoshi) j--;
if(i <= j) {

if (i < j){ swap(a[i], a[j]);q++;}

i++;
j--;
}
} while (i <= j);
if (i < last)
qs(a,i,last);
if (first < j)
qs(a,first,j);
}

int main(int args, char *argv[])

{ int n;cout<<"n=";cin>>n;
tal talaba[n];
for(int i=0;i

talaba[i].yoshi=i+1;


cin>>talaba[i].yoshi;
}
qs(talaba,0,n-1);
for(int i=0;icout<cout<<"quicksort algoritmi "<system("PAUSE");
}
Download 134.05 Kb.

Do'stlaringiz bilan baham:




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