Guruh talabasi Rajabov Islombek


Download 468.46 Kb.
bet1/2
Sana13.12.2020
Hajmi468.46 Kb.
#166140
  1   2
Bog'liq
5-Tajriba ishi topshiriqlari

914_19-guruh talabasi

Rajabov Islombek

Topshiriq


Pufaksimon saralash usulidan foydalanib, saralashni amalga oshirish dasturini ishlab chiqish (variantga mos ravishda):

  1. A massivning eng katta (eng kichik) elementini ekranga chiqarish dasturini tuzing.

#include

using namespace std;

int main(){

int n;


cout<<"n = ";

cin>>n;


int a[100];

for(int i = 1; i <= n; i++){

cin >> a[i];

}

int min = a[1];



for (int i = 2; i <= n; i++) {

if (a[i] < min)

min = a[i];

}

int max= a[1];



for (int i = 2; i <= n; i++) {

if (a[i] > max)

max = a[i];

}

cout << "Massivning minimali : " << min<

cout<<"Massivning maxsimali : "<
}




  1. A massiv elementlari qiymatlarini kamayish tartibida saralash dasturini tuzing.

#include

using namespace std;

void saralash (int a[], int n){

int i,j;


for(i=0; ifor(j=0; j

if(a[i]>a[j]) swap(a[i],a[j]);
}

}

}



int main(){

int i,n;


cout<<"N : "; cin>>n;

int a[n];

cout<

for(i=0; i>a[i];

cout<<" Kamayish tartibida saralangan massiv.\n";

saralash(a,n);

for(i=0; i

system("pause");



return 0;

}



Download 468.46 Kb.

Do'stlaringiz bilan baham:
  1   2




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