Gurux Mamatxalilov Subhonjon 1 – amaliy mashg’ulot Mavzu


Download 106.7 Kb.
bet2/2
Sana08.01.2022
Hajmi106.7 Kb.
#245412
1   2
Bog'liq
1-amaliyot (2)

1.1-rasm. Saralash algoritmi uchun blok sxema.

Dastur kodi.

#include using namespace std; int main()

{int *arr; int size;

cout << "n = "; cin >> size;

if (size <= 0) {

cerr << "Massiv hajmi 0 dan katta bo’lishi kerak." << endl; return 1;}

arr = new int[size];

for (int i = 0; i < size; i++) { cout << "arr[" << i << "] = "; cin >> arr[i];

}

int max = arr[0];



for (int i = 1; i < size; i++) { if (arr[i] > max) {

max = arr[i];

}

}

cout << "max = " << max << endl; delete [] arr;



return 0;

}

Xulosa



Men amaliy mashg’ulot tayorlash davomida Masalaning yechimini topishning optimal usulini ishlab chiqishni usularini о‘rgandim. Massivning eng katta yoki eng kichik elementini topishning optimal usullarini aniqlash va bizga eng maqul yechimni toppish uchun kerek bo’lar ekan.
Download 106.7 Kb.

Do'stlaringiz bilan baham:
1   2




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