#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
Recommended Answers
Jump to PostWell, and your question is... ???
Jump to Post> Last edited by LiquidScorpio81 : 43 Minutes Ago at 18:45.
It's a shame you didn't add the code tags."Hey, I know, lets piss off all the people who help around here by continually posting unindented crap."
Doesn't work kiddo. Either we ignore you, or just report …
Jump to Posthow do i indent ? i press tab and it just tabs over to the reply button
Indent using the space bar.
And the simplest form of using code tags is
[code]
your code here ...
[/code]
Jump to PostIt appears indented when in the text editor, once it's edited it appears non-indented.
If you don't use code tags, the indentation simply gets lost.
All 13 Replies
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.