samedi 2 mai 2015

random number generator allowing user to choose how many numbers generated?

so I was working on a random number generator, generates numbers between 250 and -250, and allows the user to choose the number of the random numbers, lets say the user inputs 5, and then the program will generates five random numbers, and if the user enters 7, it will generates 7 random numbers. and I made the program but I got to problems first I couldn't know how to make the user choose the number of the number of the random numbers, and every time I run the program it only show a i on the screen. the code I was working on:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <typeinfo>
#include <iostream>
int main ()
{
   int max = 250, min = -250;
    int randNum = rand()%(max-min + 1) + min;
    std::cout << typeid(randNum).name() << '\n';
  return 0;
}




Aucun commentaire:

Enregistrer un commentaire