0

```
#include<iostream>
using namespace std;
void BubbleSort(int ar[10], int n, int & compare_costs, int & swap_costs)
{
int t; int swaps=-1;
while(swaps)
{
swaps++;
compare_costs++;
for(int i=0; i<n-1; i++)
if(ar > ar[i+1])
{
t=ar; ar=ar[i+1]; ar[i+1]=t;
swap_costs=swap_costs+5;
}
}
}
int main()
{
int n, compare_costs, swap_costs;
int ar[10];
int *bs = new int[n];
int *ss = new int[n];
int *qs = new int[n];
srand(time(0));
for(int i=0; i<n-1; i++)
*(bs+i) = *(ss+i) = *(qs+i) = 1+rand()%100;
for(int i=0; i<n-1; i++)
cout<< *(bs+i)<< " ";
BubbleSort(bs,n,compare_costs,swap_costs);
cout<<endl;
for(int i=0; i<n-1; i++)
cout<< *(bs+i)<< " ";
}
```

*Edited 3 Years Ago by happygeek*: fixed formatting