- 1

Bubble sort

#include <iostream> using namespace std; int main() { int n; cin>>n; int arr[n]; for(int i=0;i<n;i++){ cin>>arr[i]; } int counter=1; while(counter<n){ for(int i=0;i<n-counter;i++){ if(arr[i]>arr[i+1]){ int temp=arr[i+1]; arr[i+1]=temp; } } counter++; } for(int i=0;i<n;i++){ cout<<arr[i]<<" "; } return 0; }

25th Feb 2021, 4:05 PM
soni singh
soni singh - avatar
3 ответов
+ 1
The output is incorrect
25th Feb 2021, 4:43 PM
soni singh
soni singh - avatar
0
I dont see no problems with that :3
25th Feb 2021, 4:28 PM
BUZZSAW
BUZZSAW - avatar
0
I know I said that being sarcastic. Also surprised this all happened in one day. People arn't usually active on this app unless in a class.
1st Mar 2021, 7:16 PM
BUZZSAW
BUZZSAW - avatar