Kamis, 24 Mei 2012

Program C++ Array [Bubble Short]

18.44

#include
#include

using namespace std;

class bublesort{
      //friend istream& operator>>(istream& in,buble& a);
      //friend ostream& operator<<(ostream& out,buble& a);
public:
        void buble (int data[100],int_Variable banyak);
        void tukar (
        int a,
        int b)
        }; 
 void bublesort::buble (int data[100],int_Variable banyak)
{
     
   int j;
   int k;
 

   j =1;
   while (!(j>banyak))
   {
      k =j+1;
      while (!(k>banyak))
      {
         if (data(j)>data(k))
         {
            tukar(data(j),data(k));
         }
         else
         {
         }
         k =k+1;
      }
      j =j+1;
   }
}
 void tukar (
       int a,
       int b)
{
   int temp;

   temp =a;
   a =b;
   b =temp;
}
int main()
{
   string raptor_prompt_variable_zzyz;
   int banyak;
   int i;

   bublesort a ;
   raptor_prompt_variable_zzyz ="input banyaknya data";
   cout << raptor_prompt_variable_zzyz << endl;
   cin >> banyak;
   i =1;
   while (!(i>banyak))
   {
      raptor_prompt_variable_zzyz ="inputkan data";
      cout << raptor_prompt_variable_zzyz << endl;
      cin >> data(i);
      cout << "data:"+data(i) << endl;     
      i =i+1;
   }
   a.buble(data,banyak);
   i =1;
   while (!(i>banyak))
   {
      cout << "isi data:"+data(i) << endl;     
      i =i+1;
   }

  
   system("pause");
   return 0;
}

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 komentar:

Posting Komentar

 

© 2013 Raizexe Blog. All rights resevered. Designed by Templateism

Back To Top