37 lines
436 B
C++
37 lines
436 B
C++
#include<iostream>
|
|
#include<iomanip>
|
|
using namespace std;
|
|
int main(){
|
|
|
|
int n=5,max;
|
|
bool bl=false;
|
|
int a[n]={12,22,81,94,95};
|
|
|
|
for(int i=0;i<n;i++){
|
|
|
|
for(int j=0;j<n-i-1;j++){
|
|
|
|
if(a[j]>a[j+1]){
|
|
|
|
max=a[j];
|
|
a[j]= a[j+1];
|
|
a[j+1]=max;
|
|
|
|
bl=true;
|
|
}
|
|
if (!bl)
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
for(int j=0;j<n;j++)
|
|
cout<<a[j]<<" ";
|
|
cout<<endl;
|
|
|
|
|
|
|
|
return 0;
|
|
}
|