1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int array[]={1, 5, 17, 3, 75, 4, 4, 23, 5, 12, 34, 34, 805, 345, 435, 234, 6, 47, 4, 9, 0, 56, 32, 78};
int elements=sizeof(array)/sizeof(int);
int change=1;
while(change!=0){
change=0;
for(int i=0; i<elements; i++){
if(array[i]>array[i+1]){
int temp=array[i+1];
array[i+1]=array[i];
array[i]=temp;
change+=1;
}
}
}
for(int i=0; i<elements; i++){
cout<<array[i]<<", ";
}
return 0;
}
| |