Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include "stdio.h"
- #include "stdbool.h"
- #define swap(type, i, j) {type t = i; i = j; j = t;}
- void BubbleSort(int v[], int dim) {
- int i;
- bool ordinato = false;
- while (dim>1 && !ordinato) {
- ordinato = true; /* hp: รจ ordinato */
- for (i = 0; i<dim - 1; i++)
- if (v[i]>v[i + 1]) {
- swap(int, v[i], v[i + 1]);
- ordinato = false;
- }
- dim--;
- }
- }
- int main() {
- int array[10] = { 9,3,6,7,5,4,3,2,5,11 };
- BubbleSort(array, 10);
- for (int i = 0; i < 10;i++)
- {
- printf("%d", array[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement