Last active
August 12, 2017 20:14
-
-
Save condef5/7c2e938388bc7eb2ec214a33fbcee1ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
#include <conio.h> | |
/*Problema | |
Un programa que encuentre el segundo mayor en N numeros ingresados por teclado, | |
los nuemros ingresados deben estar comprendidos entre 10 y 99 | |
*/ | |
void main(void) | |
{ | |
int minNum=10,maxNum=99,numTer,num, mayNum=0, mayTwoNum=0; | |
cout<<"Ingrese el numero de terminos"; | |
cin>>numTer; | |
for(int i = 0; i < numTer; i++){ | |
do{ | |
cout<<"Ingrese un número"<<"["<<i<<"]"; | |
cin>>num; | |
}while(num <= minNum || maxNum <= num); | |
if(num > mayNum){ | |
mayTwoNum = mayNum; | |
mayNum = num; | |
} | |
else if(num > mayTwoNum){ | |
mayTwoNum = num; | |
} | |
} | |
cout<<"El segundo mayor es: "<<mayTwoNum; | |
getch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment