Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void bubble_sort (int *a, int n) {
|
||||
int i, t, j = n, s = 1;
|
||||
while (s) {
|
||||
s = 0;
|
||||
for (i = 1; i < j; i++) {
|
||||
if (a[i] < a[i - 1]) {
|
||||
t = a[i];
|
||||
a[i] = a[i - 1];
|
||||
a[i - 1] = t;
|
||||
s = 1;
|
||||
}
|
||||
}
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
int main () {
|
||||
int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1};
|
||||
int n = sizeof a / sizeof a[0];
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
printf("%d%s", a[i], i == n - 1 ? "\n" : " ");
|
||||
bubble_sort(a, n);
|
||||
for (i = 0; i < n; i++)
|
||||
printf("%d%s", a[i], i == n - 1 ? "\n" : " ");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue