NicolasNR

Problema10

Jun 26th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. /*
  2. 10.- Leer tres números diferentes y determinar si hay número medio y su valor.  
  3. El número medio es aquel que no es ni mayor, ni menor.*/
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     float a, b, c;
  11.  
  12.     cout << "Ingrese el primer numero: ";
  13.     cin >> a;
  14.     cout << "Ingrese el segundo numero: ";
  15.     cin >> b;
  16.     cout << "Ingrese el tercer numero: ";
  17.     cin >> c;
  18.  
  19.     if (a > b && a < c || a<b && a>c)
  20.     {
  21.         cout << "El numero intermedio es: " << a << endl;
  22.     }
  23.     else if (b > a && b < c || b<a && b>c)
  24.     {
  25.         cout << "El numero intermedio es: " << b << endl;
  26.     }
  27.     else if (c > a && c < b || c<a && c>b)
  28.     {
  29.         cout << "El numero intermedio es: " << c << endl;
  30.     }
  31.     else
  32.     {
  33.         cout << "No hay algun numero intermedio";
  34.     }
  35.  
  36.     system("pause");
  37. }
Advertisement
Add Comment
Please, Sign In to add comment