Skip to main content
added 4 characters in body; edited tags
Source Link
Bill the Lizard
  • 407.3k
  • 213
  • 579
  • 892

I have a problem with the small game that iI made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runingrunning this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0))srand(time(0)) makes it dependantdependent on the current time. But how would iI make it "more" random, since I don't want the stuff to happen that iI mentioned above.

First time iI ran it the result was 11, after runingrunning it again (after guessing the right number) , it was still 11, even though the time changed.

I have a problem with the small game that i made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runing this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependant on the current time. But how would i make it "more" random, since I don't want the stuff to happen that i mentioned above.

First time i ran it the result was 11, after runing it again (after guessing the right number) , it was still 11, even though the time changed.

I have a problem with the small game that I made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After running this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependent on the current time. But how would I make it "more" random, since I don't want the stuff to happen that I mentioned above.

First time I ran it the result was 11, after running it again (after guessing the right number) , it was still 11, even though the time changed.

remove duplicate link
Source Link

Possible Duplicate:
Mysterious random number - wanting to be the same even after “srand()”

I have a problem with the small game that i made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runing this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependant on the current time. But how would i make it "more" random, since I don't want the stuff to happen that i mentioned above.

First time i ran it the result was 11, after runing it again (after guessing the right number) , it was still 11, even though the time changed.

Possible Duplicate:
Mysterious random number - wanting to be the same even after “srand()”

I have a problem with the small game that i made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runing this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependant on the current time. But how would i make it "more" random, since I don't want the stuff to happen that i mentioned above.

First time i ran it the result was 11, after runing it again (after guessing the right number) , it was still 11, even though the time changed.

I have a problem with the small game that i made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runing this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependant on the current time. But how would i make it "more" random, since I don't want the stuff to happen that i mentioned above.

First time i ran it the result was 11, after runing it again (after guessing the right number) , it was still 11, even though the time changed.

Post Reopened by casperOne
insert duplicate link
Source Link

Possible Duplicate:
Mysterious random number - wanting to be the same even after “srand()”

I have a problem with the small game that i made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runing this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependant on the current time. But how would i make it "more" random, since I don't want the stuff to happen that i mentioned above.

First time i ran it the result was 11, after runing it again (after guessing the right number) , it was still 11, even though the time changed.

I have a problem with the small game that i made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runing this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependant on the current time. But how would i make it "more" random, since I don't want the stuff to happen that i mentioned above.

First time i ran it the result was 11, after runing it again (after guessing the right number) , it was still 11, even though the time changed.

Possible Duplicate:
Mysterious random number - wanting to be the same even after “srand()”

I have a problem with the small game that i made.

#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int span = 100; srand(time(0)); int TheNumber = static_cast<double> (rand()) /RAND_MAX * (span -1) +1; cout << "You need to guess the number between 1 and " << span << endl; int mynumber; int numberofAttempts = 0; do { cout << ++numberofAttempts <<" Attempt: "; cin >> mynumber; if (mynumber > TheNumber) cout <<"Lower!" << endl; else if (mynumber < TheNumber) cout <<"Higher!" << endl; } while (mynumber != TheNumber); cout << "SUCESS!!!" << endl; return 0; } 

The game is supposed to generate a random number between 0-100 and you are supposed to guess it. After runing this code 15-20times the same numbers generated some even 8 times (the number 2 in my case).

I know that there is no absolute random number and that it uses some math formula or something to get one.I know that using srand(time(0)) makes it dependant on the current time. But how would i make it "more" random, since I don't want the stuff to happen that i mentioned above.

First time i ran it the result was 11, after runing it again (after guessing the right number) , it was still 11, even though the time changed.

added 114 characters in body
Source Link
Marink
  • 91
  • 1
  • 1
  • 8
Loading
Source Link
Marink
  • 91
  • 1
  • 1
  • 8
Loading