Earn by twitter on twivert

Sign up for PayPal and start accepting credit card payments instantly.

Thursday, March 29, 2012

WAP of Bubble Short in C++

/*WAP of Bubble Short in C++*/
#include<iostream.h>
#include<conio.h>

class bubbleShort
{
 int size, a[100];
 public:
 void getdata();
 void sorting();

};
void bubbleShort :: getdata()
{
 int i;
 cout << "\nEnter total number of elements: " ;
 cin >> size;

 
 cout << "\nEnter elements: ";
 for(i=0;i<size;i++)
  cin >> a[i];

 cout << "\nEntered elements are: ";
 for(i=0;i<size;i++)
  cout << a[i] << " ";

}
void bubbleShort :: sorting()
{

 int i,j,temp;
 for(i=1;i<size;i++)
 {
  for(j=0;j<size-i;j++)
  {
   if(a[j]>a[j+1])
   {
    temp=a[j];
    a[j]=a[j+1];
    a[j+1]=temp;
   }
  }
 }
 
 cout << "\nElements After Shorting:";
 for(i=0;i<size;i++)
  cout << "\n" << a[i];

}

void main()
{
 clrscr();
 bubbleShort bsrch;
 bsrch.getdata();
 bsrch.sorting();

 getch();
}

No comments:

Post a Comment

ADS

How to earn online

How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 : Singup these 4 sites & earn & enjoy! Read site to know how to earn.
1. trekpay
Earn up to $0.02 (2 cents) per click.
http://www.trekpay.com/?ref=34690
2. neobux
Earn up to $0.02 (2 cents) per click.
Click here:
http://www.neobux.com/?r=Moneyearner786

AddMe

Bookmark and Share