We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 94ae8b2 commit bf3979aCopy full SHA for bf3979a
Bubble-Sort.cpp
@@ -0,0 +1,39 @@
1
+#include <cstdio>
2
+#include <cstdlib>
3
+
4
+using namespace std;
5
6
+int data[1000];
7
8
+void bubble_sort(int *d, int n)
9
+{
10
+ for (int k = 1; k < n; k++)
11
+ {
12
+ for (int i = 1; i < n; i++)
13
14
+ if (d[i] < d[i - 1])
15
16
+ int temp = d[i];
17
+ d[i] = d[i - 1];
18
+ d[i - 1] = temp;
19
+ }
20
21
22
+}
23
24
+int main()
25
26
+ for (int i = 0; i < 1000; i++)
27
28
+ data[i] = rand();
29
30
31
+ bubble_sort(data, 1000);
32
33
34
35
+ printf("%d\n", data[i]);
36
37
38
+ return 0;
39
0 commit comments