1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
void randNumber (int n1, int n2, int a[][4])
{
if((n1 == 4) && (n2 == 3))
{
b = rand() % 7;
c = rand() % 4;
randNumber(b, c, a);
}
/*else if (...other numbers that are not allowed...)
{
b = rand() % 7;
c = rand() % 4;
randNumber(b, c, a);
}*/
else if (a[n1][n2] == a[n1][n2]) // i think the problem is here
{
b = rand() % 7;
c = rand() % 4;
randNumber(b, c, a);
}
else
{
cout << n1 << " " << n2 << " " << "\n";
cout << a[n1][n2] << " ";
}
cout << "\n";
}
int random(int a[][4])
{
int r1[4];
int r2[4];
srand(time(NULL));
for( int i = 0; i < 4; i++)
{
r1[i] = rand() % 7;
r2[i] = rand() % 4;
if((r1[i] == 4) && (r2[i] == 3))
{
b = rand() % 7;
c = rand() % 4;
randNumber(b, c, a);
}
/*else if (...other numbers that are not allowed...)
{
b = rand() % 7;
c = rand() % 4;
randNumber(b, c, a);
}*/
else if (a[r1[i]][r2[i]] == a[r1[i]][r2[i]]) // i think the problem is here
{
b = rand() % 7;
c = rand() % 4;
randNumber(b, c, a);
}
else
{
cout << r1 << " " << r2 << " " << "\n";
cout << a[r1[i]][r2[i]] << " ";
}
cout << "\n";
}
}
|