lindzwiat2707 lindzwiat2707
  • 19-07-2019
  • Computers and Technology
contestada

write a program that implement a bubble sort ?

Respuesta :

Numenius
Numenius Numenius
  • 26-07-2019

Answer:

 A program that implement a bubble sort:

 #include<iostream.h>

 #include<conio.h>

 

int main()

{

int ar[50],no,i,j,temp;

cout<<"Enter array size ";

cin>>no;

cout<<"Enter array elements ";  

 

for(i=0;i<no;++i)

 cin>>ar[i];

 

for(i=1;i<no;++i)

{

 for(j=0;j<(no-i);++j)

  if(ar[j]>ar[j+1])

  {

   temp=ar[j];

   ar[j]=ar[j+1];

   ar[j+1]=temp;

  }

}

 

cout<<"Bubble Sort array";

for(i=0;i<no;++i)

 cout<<" "<<ar[i];

 

return 0;

}

Answer Link

Otras preguntas

what stated of matter and how many phases are present when a 5.0 mL sample of oil is mixed with 100.0 mL of water?A both solid and liquid state= two phasesB two
Bobbi wanted to purchase a shirt that had an original price of $38.99 at the store where she works. She gets an employee discount of 25%. How much will she need
solve for the variable x 3(2x+4y)-4=8
3x+2y=-3-3x+y=12 I need help pls!!!
Now expand the the expression
Whats the propositional phrase in The editor of the newspaper wanted to publish it.’
I don’t know how i’m supposed to do this it’s basically dividing a fraction with a fraction or something
Question Write an equation of the line passing through the point A(3, −1) that is parallel to the line y = 1/3x+10.
the sum of two numbers is 23 and their difference is 5. Let the two numbers be x and y. Write two equations and solve them to find the two numbers
help ? yes ? no ? maybe