Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #ifndef DEBUG
- #define DEBUG(...) printf(__VA_ARGS__)
- #endif
- #define SIZE 512
- // Implementirati funkciju za bubble sort
- void bubble_sort(int n, int array[]) {
- for (int i = 0; i < n; ++i)
- {
- for (int j = 1; j < n; ++j)
- {
- if(array[j - 1] < array[j]){
- int tmp = array[j - 1];
- array[j - 1] = array[j];
- array[j] = tmp;
- }
- }
- }
- }
- int main() {
- int n, array[SIZE];
- scanf("%d", &n);
- for (int i = 0; i < n; i++) {
- scanf("%d", &array[i]);
- }
- // Dodati poziv funkcije za sortiranje
- bubble_sort(n, array);
- for (int i = 0; i < n; i++) {
- printf("%d ", array[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement