c++ - How can I define RAND_MAX -


how create program generates ten random numbers 1 -> rand_max?

rand_max must number input user.

int main() { using namespace std; int x; int y; random: { x = rand(); cout << x << endl; } y = y + 1; if (y == 10) {     return 0; } goto random; } 

something like:

int main() {   int randmax;   cin >> randmax;   (int y = 0; y < 10; y++)   {     int x = rand() % randmax; // range = [0, randmax)     cout << x+1 << endl; // range = [1, randmax]   } } 

oh, , try avoid goto (at least in opinion). here two questions it.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -