Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Hacer un programa para ingresar una lista de números que finaliza cuando se ingresa un cero, luego informar el máximo.
- Ejemplo: 5, 10, 20, 8, 25, 13, 35, -8, -5, 20, 0. Se listará Máximo 35.
- Ejemplo: 5, 10, 20, 8, 55, 13, 55, -8, -5, 20, 0. Se listará Máximo 55.
- Ejemplo: -5, -10, -20, -8, -55, -13, -55, -8, -15, -20, 0. Se listará Máximo -5
- */
- #include<iostream>
- using namespace std;
- int main(void)
- {
- int n;
- int maxnum;
- cout<< " Ingrese un numero: "<<endl;
- cin>>n;
- maxnum=n;
- while(n!=0)
- {
- if(n>maxnum)
- {
- maxnum=n;
- }
- /* else if(maxnum>n)
- {
- maxnum=n;
- }*/
- cout<< " Ingrese un numero: "<<endl;
- cin>>n;
- }
- cout<<"El maximo es: "<<maxnum<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment