Fandom

Scratchpad

PLE:Unidad22Ejercicio09

216,262pages on
this wiki
Add New Page
Discuss this page0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

/*
Programa:       Ejercicio09.cpp
Fecha:          20/10/2007
Descripción:    Muestra tres número ordenados ascendentemente
*/
#include <iostream>
using namespace std;
void main()
{
        int a, b, c;
        cout << endl << "Introduzca un numero ";
        cin >> a;
        cout << endl << "Introduzca otro numero ";
        cin >> b;
        cout << endl << "Introduzca otro numero ";
        cin >> c;

        if(a <= b && a <= c) // el menor es a
        {
                if(b <= c) // a b c
                        cout << a << ',' << b << ',' << c;
                else      // a c b
                        cout << a << ',' << c << ',' << b;
        }
        else if(b <= a && b <= c) // el menor es b
        {
                if(a <= c) // b a c
                        cout << b << ',' << a << ',' << c;
                else      // b c a
                        cout << b << ',' << c << ',' << a;
        }
        else // El menor es c
        {
                if(a <= b) // c a b
                        cout << c << ',' << a << ',' << b;
                else      // c b a
                        cout << c << ',' << b << ',' << a;
        }

        cin.ignore();
        cin.get();
}

Also on Fandom

Random wikia