-
Notifications
You must be signed in to change notification settings - Fork 0
/
5.cpp
67 lines (53 loc) · 1.08 KB
/
5.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
@Author: Amritanshu Sikdar
Session: 2018-'19
Repository: https://github.com/amritanshusikdar/CS30PracticalQuestion
*/
// Program to accept 10 numbers and print in descending order using Bubble Sort
#include<iostream.h>
#include<conio.h>
void input(int *array);
void BubSort(int *array);
void display(int *array);
void main()
{
clrscr();
int *array;
input(array);
BubSort(array);
display(array);
getch();
}
void input(int *array)
{
for(int i=0; i<10; i++)
{
cout << "A[" << i+1 << "]: ";
cin >> *(array+i);
}
cout << "Input Successful! \n\n";
}
void BubSort(int *array)
{
int i = 0, j, temp;
do
{
for(j = 0; j < 10-i-1; j++)
{
if(*(array+j) > *(array+j+1))
{
temp = *(array+j);
*(array+j) = *(array+j+1);
*(array+j+1) = temp;
}
}
i++;
}while(i < 10);
}
void display(int *array)
{
for(int i=9; i>=0; i--)
{
cout << "A[" << i+1 << "]: " << *(array+i) << endl;
}
}