-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask3.cpp
More file actions
46 lines (36 loc) · 873 Bytes
/
task3.cpp
File metadata and controls
46 lines (36 loc) · 873 Bytes
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
#include <iostream>
using namespace std;
void swap(int *x, int*y)
{
float temp;
temp = *x;
*x = *y;
*y = temp;
}
void BubbleSort(int arr[], int size)
{
for (int i = 0; i < size - 1; i++)
{
for (int j = i+1; j < size; j++)
{
if (arr[i] > arr[j])
{
swap(arr[i], arr[j]);
}
}
}
}
int main()
{
const int size = 40;
int arr[size] = {24, 23, 25, 25, 26, 30, 30, 33, 23, 32,
21, 26, 24, 24, 27, 26, 30, 24, 26, 28,
24, 23, 39, 26, 34, 25, 24, 26, 24, 23,
24, 29, 25, 26, 30, 22, 23, 28, 25, 24};
BubbleSort(arr, size);
for (int i = 0; i < size; i++)
{
cout << arr[i] << " ";
}
return 0;
}