orlandoju

Ejer12_tp3

Apr 12th, 2022 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(void){
  6.  
  7.         int i,n,primermax,segundomax;
  8.          bool bansegundomax=false;
  9.  
  10.         cout<< " Ingrese la cantidad de 5 numeros: "<<endl;
  11.         cout<<"--------------------"<<endl;
  12.  
  13.         for (i = 0; i < 5; i++)
  14.         {
  15.         cin >> n;
  16.         cout<<"--------------------"<<endl;
  17.         if(i==0)
  18.         {
  19.             primermax=n;
  20.           /*  segundomax=primermax;*/
  21.         }
  22.         else if( n>=primermax){
  23.          segundomax=primermax;
  24.             primermax=n;
  25.         }
  26.         else
  27.         {
  28.             if(n< primermax && bansegundomax== false)
  29.             {  
  30.                 segundomax=n;
  31.                 bansegundomax=true;
  32.             }
  33.         }
  34.         /*    else if(n<=primermax){
  35.             n=segundomax;
  36.         }*/
  37.         }
  38.         cout<<"--------------------"<<endl;
  39.         cout<< "El Numero maximo es: "<<primermax<<endl;
  40.         cout<<"--------------------"<<endl;
  41.         cout<< "El numero que le sigue al maximo es: "<<segundomax<<endl;
  42.  
  43.     return 0;
  44. }
Add Comment
Please, Sign In to add comment