+ 1
How to create bubble sort in C
how could is happend explain
2 Respuestas
+ 7
#include <iostream>
using namespace std;
int main()
{
int arr[] = {4, 6, 1, 3, 8, 5, 9};
int size = sizeof(arr) / sizeof(arr[0]);
//Bubble Sorting Start
for(int i = 0; i < size; i++)
{
for(int j = 0; j < size - 1; j++)
{
if(arr[j] > arr[j+1])
{
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
//Bubble Sorting End
for(int i = 0; i < size; i++)
cout << arr[i] << " ";
return 0;
}
+ 1
Ronak Paul , go through below link and feel free to ask if u don't get anything:
https://googleweblight.com/i?u=https://fahad-cprogramming.blogspot.com/2014/05/bubble-sort-in-c-code-example.html?m%3D1&hl=en-IN