Your name is very dutch, :P. Also "\mijn documenten". Anyway I will post a little program I made one day which uses the random funcion but will not use it twice:
PHP Code:
#include <iostream>
#include <windows.h>
using namespace std;
string S [ 256 ] [ 256 ],
S2 [ 256 ] [ 256 ],
C;
int i,
j,
k,
l [ 256 ] [ 256 ],
m [ 256 ] [ 256 ],
n [ 256 ] [ 256 ],
o,
p [ 256 ] [ 256 ],
NO [ 256 ] [ 256 ];
int main()
{
cout<< "How many words?: ";
cin>> C;
if ( isdigit ( C [ 0 ] ) &&
isdigit ( C [ 1 ] ) || C [ 1 ] == '\0' &&
isdigit ( C [ 2 ] ) || C [ 2 ] == '\0' )
{
i = atoi ( C.c_str() );
if ( i < 1 || i > 100 )
{
system ( "cls" );
cout<< "Wrong Input!";
cin.ignore();
cin.get();
exit ( 0 );
}
}
else
{
system ( "cls" );
cout<< "Wrong Input!";
cin.ignore();
cin.get();
exit ( 0 );
}
system ( "cls" );
NO [ '\0' ] [ 1 ] = 2;
i++;
for ( j = 1; j < i; j++ )
{
cout<< "Enter here the NL word: ";
cin>> S [ j ] [ '\0' ];
cout<< endl;
cout<< "Enter here the OL word: ";
cin>> S [ '\0' ] [ j ];
cout<< endl;
}
i--;
system ( "cls" );
for ( l [ 1 ] [ '\0' ] = 0, l [ '\0' ] [ 1 ] = 0, n [ 1 ] [ '\0' ] = 0, n [ '\0' ] [ 1 ] = 0, p [ 1 ] [ '\0' ] = 0, p [ '\0' ] [ 1 ] = 0; ( l [ 1 ] [ '\0' ] + l [ '\0' ] [ 1 ] ) < ( i * 2 ); )
{
srand ( ( unsigned ) time ( 0 ) );
if ( NO [ '\0' ] [ 1 ] == 0 )
{
NO [ 1 ] [ '\0' ] = 0;
}
else if ( NO [ '\0' ] [ 1 ] == 1 )
{
NO [ 1 ] [ '\0' ] = 1;
}
else if ( NO [ '\0' ] [ 1 ] == 2 )
{
NO [ 1 ] [ '\0' ] = rand() % 2;
}
if ( NO [ 1 ] [ '\0' ] == 1 )
{
k = '\0';
j = rand() % i + 1;
for ( o = 1; o < i; o++ )
{
if ( m [ o ] [ '\0' ] == j )
{
o = 0;
j = rand() % i + 1;
}
}
n [ 1 ] [ '\0' ]++;
m [ n [ 1 ] [ '\0' ] ] [ '\0' ] = j;
l [ 1 ] [ '\0' ]++;
if ( l [ 1 ] [ '\0' ] >= i )
{
NO [ '\0' ] [ 1 ] = 0;
}
}
if ( NO [ 1 ] [ '\0' ] == 0 )
{
j = '\0';
k = rand() % i + 1;
for ( o = 1; o < i; o++ )
{
if ( m [ '\0' ] [ o ] == k )
{
o = 0;
k = rand() % i + 1;
}
}
n [ '\0' ] [ 1 ]++;
m [ '\0' ] [ n [ '\0' ] [ 1 ] ] = k;
l [ '\0' ] [ 1 ]++;
if ( l [ '\0' ] [ 1 ] >= i )
{
NO [ '\0' ] [ 1 ] = 1;
}
}
cout<< S [ j ] [ k ]<< " means: ";
cin>> S2 [ k ] [ j ];
cout<< endl;
if ( S2 [ k ] [ j ] == S [ k ] [ j ] )
{
cout<< "Correct!";
Sleep ( 1000 );
p[ 1 ] [ '\0' ]++;
}
else
{
cout<< "Wrong!";
Sleep ( 1000 );
p [ '\0' ] [ 1 ]++;
}
system ( "cls" );
}
cout<< "Done!"<< endl<< endl;
cout<< "You had "<< p [ 1 ] [ '\0' ]<< " correct awnsers and "<< p [ '\0' ] [ 1 ]<< " wrong awnsers."<< endl<< endl;
cout<< "Your score would be "<< ( ( p [ 1 ] [ '\0' ] * 100 ) / ( i * 2 ) )<< "% out of 100%";
cin.ignore();
cin.get();
}