Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<ctime>
- using namespace std;
- int main()
- {
- int limite_inferior = 0;
- int limite_superior = 100;
- float n;
- // validar numero
- do{
- cout<<"Ingrese un numero entero y positivo: ";
- cin>>n;
- }
- while(int(n)!=n or n<0);
- srand(time(NULL));
- int mayor = 0;
- for(int i=0 ; i<n ; i++){
- int numero_aleatorio = limite_inferior + rand()%(limite_superior - limite_inferior + 1);
- cout<<numero_aleatorio<<" ";
- if(numero_aleatorio>mayor){
- mayor = numero_aleatorio;
- }
- }
- cout<<"\nEl mayor numero es: "<<mayor<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement