We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f5f1113 commit e5f3fcbCopy full SHA for e5f3fcb
Sorting/bubble_sort.cpp
@@ -0,0 +1,32 @@
1
+# include <iostream>
2
+using namespace std;
3
+
4
+int main()
5
+{
6
+ cout<<"Enter the length of array"<<endl;
7
+ int m, temp,n;
8
+ cin>>n;
9
+ int arr[n];
10
+ cout<<"Enter the elements of array"<<endl;
11
+ for (int i = 0; i < n; i++)
12
+ {
13
+ cin>>arr[i];
14
+ }
15
16
17
+ for (int j= 0; j< n-1; j++)
18
19
+ if (arr[j]>arr[j+1])
20
21
+ temp = arr[j];
22
+ arr[j] = arr[j+1];
23
+ arr[j+1] = temp;
24
25
26
27
+ for (int i = 0; i < n; ++i)
28
29
+ cout<<arr[i]<<" ";
30
31
+ return 0;
32
+}
0 commit comments