Skip to content

Instantly share code, notes, and snippets.

@condef5
Last active August 12, 2017 20:14
Show Gist options
  • Save condef5/7c2e938388bc7eb2ec214a33fbcee1ef to your computer and use it in GitHub Desktop.
Save condef5/7c2e938388bc7eb2ec214a33fbcee1ef to your computer and use it in GitHub Desktop.
#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