-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbubblecode.html
More file actions
53 lines (47 loc) · 1.06 KB
/
bubblecode.html
File metadata and controls
53 lines (47 loc) · 1.06 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<style>
body {padding-top:50px ; margin-top: auto; margin-left: 30px;background-color:#0c7b93;color: white}
h1 {text-align: center; color: black;}
</style>
</head>
<body>
<h1>BUBBLE SORT
<div class="">
<button onclick="location.href='index.html'">Go to Home Page</button> <br /><br />
</div>
</h1>
#include <stdio.h><br /><br>
using namespace std;<br>
void bubblesort(int arr[],int i,int n){<br>
for(int i=0;i<n-1;i++)<br>
{<br>
for(int j=0;j<n-i-1;j++)<br>
{<br>
if(arr[j]>arr[j+1])<br>
swap(arr[j],arr[j+1]);<br>
}
}
}<br>
int main()<br>
{<br>
int n;<br>
cout<<"Enter number of elements\n";<br>
cin>>n;<br>
int A[n];<br>
for(int i=0;i<n;i++)<br>
{<br>
cin>>A[i];
}<br>
bubbleSort(A,n);<br / >
cout<<"Sorted Array is\n";<br / >
for(int i=0;i < n;i++)
{<br / >
cout< < A[i]<<" ";
}<br / >
}<br / >
</body>
</html>