```
#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)<< " ";
}
```

LiquidScorpio81 0 Newbie Poster

ArkM 1,090 Postaholic

LiquidScorpio81 0 Newbie Poster

Salem 5,138 Posting Sage

LiquidScorpio81 0 Newbie Poster

LiquidScorpio81 0 Newbie Poster

mitrmkar 1,056 Posting Virtuoso

LiquidScorpio81 0 Newbie Poster

mitrmkar 1,056 Posting Virtuoso

LiquidScorpio81 0 Newbie Poster

VernonDozier 2,218 Posting Expert Featured Poster

entei 0 Newbie Poster

LiquidScorpio81 0 Newbie Poster

VernonDozier 2,218 Posting Expert Featured Poster

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.