forked from bzzzil/tiiit10_2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbubble.cpp
More file actions
30 lines (25 loc) · 787 Bytes
/
Copy pathbubble.cpp
File metadata and controls
30 lines (25 loc) · 787 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
#include <iostream>
using namespace std;//íå áûëî èñïîëüçîâàíî ïðñîòðàíñòâî èì¸í, õîÿò ïèñàëè cout
int main() {
int arr[] = {64, 34, 34, 25, 61, 12, 22, 11, 90, 42, 99};
int n = sizeof(arr)/sizeof(arr[0]);
cout << "Original: ";
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";//îøèáêà íå áûë çàêðûò ìàññèâ ]
}
cout << endl;
for (int i = 0; i < n-1; i++) {
for (int j = 0; j < n-i-1; j++) {
if (arr[j] > arr[j+1]) {
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
cout << "Output: ";//çäåñü áûëà îøèáêà ïðîïóùåíà <
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
return 0;