// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
void bubble_sort(int a[]){
// int ar[7]=a[7];
for(int i=0;i<7;i++){
for(int j=0;j<7-i-1;j++){
if(a[j]>a[j+1]){
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
for(int k=0;k<7;k++){
cout << a[k] << " "; }
cout << endl;
}
// printing sorted array
cout << "Array after implementing bubble sort to it : ";
for(int i=0;i<7;i++){
cout << a[i] << " ";
}
}
int main() {
int arr[7];
cout << "Enter elements of array : ";
for(int i=0;i<7;i++){
cin>> arr[i];
}
bubble_sort(arr);
return 0;
}
Ly8gT25saW5lIEMrKyBjb21waWxlciB0byBydW4gQysrIHByb2dyYW0gb25saW5lCiNpbmNsdWRlIDxpb3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdm9pZCBidWJibGVfc29ydChpbnQgYVtdKXsKICAgIC8vIGludCBhcls3XT1hWzddOwogICAgZm9yKGludCBpPTA7aTw3O2krKyl7CiAgICAgICAgZm9yKGludCBqPTA7ajw3LWktMTtqKyspewogICAgICAgICAgICBpZihhW2pdPmFbaisxXSl7CiAgICAgICAgICAgICAgICBpbnQgdGVtcD1hW2pdOwogICAgICAgICAgICAgICAgYVtqXT1hW2orMV07CiAgICAgICAgICAgICAgICBhW2orMV09dGVtcDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IoaW50IGs9MDtrPDc7aysrKXsKICAgICAgICAgICAgICAgIGNvdXQgPDwgYVtrXSA8PCAiICI7IH0KICAgICAgICBjb3V0IDw8IGVuZGw7CiAgICB9CiAgICAKICAgIC8vIHByaW50aW5nIHNvcnRlZCBhcnJheQogICAgY291dCA8PCAiQXJyYXkgYWZ0ZXIgaW1wbGVtZW50aW5nIGJ1YmJsZSBzb3J0IHRvIGl0IDogIjsKICAgIGZvcihpbnQgaT0wO2k8NztpKyspewogICAgICAgIGNvdXQgPDwgYVtpXSA8PCAiICI7CiAgICB9Cn0KaW50IG1haW4oKSB7CiAgICBpbnQgYXJyWzddOwogICAgY291dCA8PCAiRW50ZXIgZWxlbWVudHMgb2YgYXJyYXkgOiAiOwogICAgZm9yKGludCBpPTA7aTw3O2krKyl7CiAgICAgICAgY2luPj4gYXJyW2ldOwogICAgfQogICAgYnViYmxlX3NvcnQoYXJyKTsKICAgIHJldHVybiAwOwogICAgCn0K