Rabu, 05 Oktober 2011

Struktur Pemilihan (Part 3)


Program sederhana mengurutkan bilangan dari 3 input bilangan bulat !
  
// tugaspendahuluan2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream.h"
#include "conio.h"
int main()
{
     int a;int b;int c;


     cout<<"Masukkan nilai a "<<endl;
     cin>>a;
     cout<<"Masukkan nilai b "<<endl;
     cin>>b;
     cout<<"Masukkan nilai c "<<endl;
     cin>>c;


     if ((a>b)&&(a>c))
     {
           cout<<a<<",";
           if (b>c)
                cout<<b<<","<<c<<endl;
           else
                cout<<c<<","<<b<<endl;
     }
     else
     {
           if ((b>a)&&(b>c))
           {
                cout<<b<<",";
                if (a>c)
                     cout<<a<<","<<c<<endl;
                else
                     cout<<c<<","<<a<<endl;
           }
           else
           {
                if ((c>b)&&(c>a))
                {
                     cout<<c;
                     if (b>a)
                           cout<<b<<","<<a<<endl;
                     else
                           cout<<a<<","<<b<<endl;;
                }
           }
     }
    
     getch();
     return 0;

0 komentar:

Posting Komentar

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Laundry Detergent Coupons