-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBubble_sort.cpp
50 lines (41 loc) · 875 Bytes
/
Bubble_sort.cpp
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
/*
Author: Parth Shah
Visualgo.net Data Structures Practice.
Bubble_Sort Implementation using random number generator.
This sorting can be done on different data type such as Char, string, double.
Just change the type.
*/
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
srand(time((0)));
int random_num = rand() %10 + 1;
cout << random_num;
/*
//Creating an array with fixed size.
int numbers[10];
//Sorting algorithm.
for(int i=0; i<=8; i++)
{
int temp;
for(int j=i+1; j<=9; j++)
{
if(numbers[i]> numbers[j])
{
temp = numbers[i];
numbers[i]= numbers[j];
numbers[j] = temp;
}
}
}
for(int i=0; i <10 ; i++)
{
cout << "Numbers in sorted form are: " << numbers[i] << "\n ";
}
cin.get();
*/
return 0;
}