-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hyejun
committed
Jun 15, 2020
1 parent
f1038b8
commit 00a493b
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
|
||
void bubble_sort(int arr[], int count) { | ||
int temp, i, j; | ||
|
||
for (i = 0; i < count; i++) { | ||
for (j = 0; j < count - 1; j++) { | ||
if (arr[j] > arr[j + 1]) { | ||
temp = arr[j]; | ||
arr[j] = arr[j + 1]; | ||
arr[j + 1] = temp; | ||
} | ||
} | ||
} | ||
} | ||
|
||
int main() { | ||
int numArr[10], i; | ||
for (i = 0; i < 10; i++) { | ||
scanf("%d", &numArr[i]); | ||
} | ||
bubble_sort(numArr, sizeof(numArr) / sizeof(int)); | ||
|
||
for (i = 0; i < 10; i++) { | ||
printf("%d ", numArr[i]); | ||
} | ||
printf("\n"); | ||
|
||
return 0; | ||
} |