Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(void){
- int i,n,primermax,segundomax;
- bool bansegundomax=false;
- cout<< " Ingrese la cantidad de 5 numeros: "<<endl;
- cout<<"--------------------"<<endl;
- for (i = 0; i < 5; i++)
- {
- cin >> n;
- cout<<"--------------------"<<endl;
- if(i==0)
- {
- primermax=n;
- /* segundomax=primermax;*/
- }
- else if( n>=primermax){
- segundomax=primermax;
- primermax=n;
- }
- else
- {
- if(n< primermax && bansegundomax== false)
- {
- segundomax=n;
- bansegundomax=true;
- }
- }
- /* else if(n<=primermax){
- n=segundomax;
- }*/
- }
- cout<<"--------------------"<<endl;
- cout<< "El Numero maximo es: "<<primermax<<endl;
- cout<<"--------------------"<<endl;
- cout<< "El numero que le sigue al maximo es: "<<segundomax<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment