[code]#include <iostream>
#include <time.h>
using namespace std;
int main()
{
srand(time(NULL));
int B1 = random()%35 + 1;
int B2 = random()%35 + 1;
int B3 = random()%35 + 1;
int B4 = random()%35 + 1;
int B5 = random()%35 + 1;
while (B2 == B1)
while (B3 == B1 || B3 == B2);
while (B4 == B1 || B4 == B2 || B4 == B3)
while (B5 == B1 || B5 == B4 || B5 == B3 || B5 == B2)
int R = rand()5% + 1;
if (R==1)cout << "Low number\n";
if (R==2)cout << "wowsers\n";
if (R==3)cout << "unbelieveable\n";
if (R==4)cout << " Your a champ\n";
if (R==5)cout << " God is with you\n";
return 0;
i am getting these errors when i compile it
random.cpp: In function âint main()â:
random.cpp:23: error: expected â,â or â;â before numeric constant
random.cpp:24: error: âRâ was not declared in this scope
random.cpp:25: error: âRâ was not declared in this scope
random.cpp:26: error: âRâ was not declared in this scope
random.cpp:27: error: âRâ was not declared in this scope
random.cpp:28: error: âRâ was not declared in this scope
You would probably find it easier to use an array of 35ints (1-35) can be done with a simple loop.
1 2
int array[35], limit = 35, temp;
for(int i=0;i<limit<i++){array[i] = i;}
Then randomise a number between 0 and 36, or -1 and 35.
Then you could either get the value of: array[picked - 1]
or array[picked]
Depending on which boundaries you set for random.