orlandoju

ejer2_tp4

Apr 22nd, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. /*
  2. Hacer un programa para ingresar una lista de números que finaliza cuando se ingresa un cero, luego informar el máximo.
  3. Ejemplo: 5, 10, 20, 8, 25, 13, 35, -8, -5, 20, 0. Se listará Máximo 35.
  4. Ejemplo: 5, 10, 20, 8, 55, 13, 55, -8, -5, 20, 0. Se listará Máximo 55.
  5. Ejemplo: -5, -10, -20, -8, -55, -13, -55, -8, -15, -20, 0. Se listará Máximo -5
  6. */
  7. #include<iostream>
  8. using namespace std;
  9.  
  10.  
  11. int main(void)
  12. {
  13.     int n;
  14.     int maxnum;
  15.     cout<< " Ingrese un numero: "<<endl;
  16.     cin>>n;
  17.     maxnum=n;
  18.     while(n!=0)
  19.     {
  20.         if(n>maxnum)
  21.         {
  22.             maxnum=n;
  23.         }
  24.       /*  else if(maxnum>n)
  25.         {
  26.             maxnum=n;
  27.         }*/
  28.         cout<< " Ingrese un numero: "<<endl;
  29.         cin>>n;
  30.     }
  31.     cout<<"El maximo es: "<<maxnum<<endl;
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment