11 Ro`yhat elementlarini kamayish tartibida joylashtirilsin


Download 277.54 Kb.
Sana02.02.2023
Hajmi277.54 Kb.
#1147363
Bog'liq
MTA



11) Ro`yhat elementlarini kamayish tartibida joylashtirilsin.
#include
using namespace std;
#define MAX 100
int main()
{
int arr[MAX];
int n,i,j;
int temp;
cout<<"Elementlar sonini kiriting: ";
cin>>n;
if(n<0 || n>MAX){
cout<<"Input valid range!!!"< return -1;
}
for(i=0;i cout<<" ["< cin>>arr[i];
}
cout<<"Saralanmagan ro'yhat elementlari: "< for(i=0;i cout< cout< for(i=0;i {
for(j=i+1;j {
if(arr[i] {
temp =arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
cout<<"Kamayish tartibida saralangan ro'yhat :"< for(i=0;i cout< cout<
return 0;
}

Natija: Elementlar sonini kiriting: 6
[1] - elementni kiriting: 3
[2] - elementni kiriting: 98
[3] - elementni kiriting: 14
[4] - elementni kiriting: 48
[5] - elementni kiriting: 24
[6] - elementni kiriting: 100
Saralanmagan ro'yhat elementlari:
3 98 14 48 24 100
Kamayish tartibida saralangan ro'yhat :
100 98 48 24 14 3

Download 277.54 Kb.

Do'stlaringiz bilan baham:




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