EnglishFrenchGermanSpainItalianDutchPortugueseRussianKoreanJapaneseArabic Chinese Simplified

Monday, June 13, 2011

Sorting Data with Bubble Sort methods

Ordering is one of the basic process that is often discussed in algorithms and data structures. And one of the simplest classical algorithms in terms of sorting (sorting) is the Bubble Sort algorithm. In spite of some deficiencies which make these algorithms are not widely used in the sorting process in the application, but not be denied, this algorithm can be described as the pioneer of the sorting algorithm. Within the courses algorithms and Data structures in various colleges can also be included in the sorting algorithm using the Bubble concept as one of the subject.
#include<iostream>
#include<conio>

void main()
{
   int data[10];
   int i, j, tmp;
   cout<<"Mengurutkan Data"<<endl;
   cout<<"Dengan Metode Bubble Sort"<<endl;
   for(i=0; i<10; i++)
   {
       cout<<"Masukkan bilangan ke "<<(i+1)<<" : ";
      cin>>data[i];
   }
   clrscr();
   cout<<"Data sebelum diurutkan : "<<endl;
   for(i=0; i<10; i++)
   {
       cout<<data[i]<<" ";
   }
   cout<<endl;

   for(i=0; i<9; i++)
   {
       for(j=i+1; j<10; j++)
      {
          if(data[i]>data[j])
         {
             tmp = data[i];
            data[i] = data[j];
            data[j] = tmp;
         }
      }
   }
   cout<<"Data setelah diurutkan : "<<endl;
   for(i=0; i<10; i++)
   {
       cout<<data[i]<<" ";
   }
   getch();
}

Artikel Terkait:

Comments :

0 comments to “Sorting Data with Bubble Sort methods”

Post a Comment

 

Copyright © 2009 by Learn Technology

Template by Blogger Templates | Powered by Blogger