Thursday, 24 January 2013

Sorting

#include <iostream>

using namespace std;

int main()
{

    int temp;
    int mango[5];
    for(int k=0; k<5;k++)
    {
    cin >> mango[k];
    }



    for(int j=0;j<5-i;j++)

      {
           if(mango[j]<mango[j+1])
           {
           temp = mango[j];
           mango[j]=mango[j+1];
           mango[j+1]=temp;

           }

     }



    for (int k=0;k<5;k++)
    {

    cout << mango[k] << "  ";
    }

   cin.get();
    return 0;
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management