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

PLEASE HELP W PRECALC QUESTION
List some of the things that you believe that are affecting businesses and our economy:​
Why does Dallas think Cherry refused to get a coke with him? Does Ponyboy agree with his reasoning?
Will give brainliest for right answer! :)
President Mujica believed in the power of the youth to bring about change. Which two sentences in his speech describes how he implores the youth not to waste th
PLEASE HELP BECAUSE I DON"T KNOW INTEGRATION WITH TRIG SUBSTITUTION!!! WILL GIVE BRAINLIEST + 20 POINTS!!!
You are taking measurements of sound waves. Every ¼ second, the sound waves pass your detector. What is the wave’s frequency and what is the wave’s period? (Use
Hey There , Please Help Me With This Question ! Dont Forget To Show Your Work Thank You <3 -Needs Answer Right Now -
another question plssss
differentiate between condensation polymerization and addition polymerization​