topic description
Program to implement bubble sorting, sort in non-decreasing order, and the test data is an integer.
enter
The first line is the number of data elements to be sorted; the second line is the data elements to be sorted.
output
The first line outputs the result of the first bubble sort.
#include<bits/stdc++.h>
using namespace std;
int a[1005], m;
int main(){
cin>>m;
for(int i = 0; i < m; i++) cin>>a[i];
for(int i = 0; i < m - 1; i++) if(a[i] > a[i+1]) swap(a[i], a[i+1]);
for(int i = 0; i < m; i++ ) cout<<a[i]<<" ";
return 0;
}