C/C++ Programming
Total Pageviews
Wednesday, May 12, 2010
Lesson 6 - Generate random numbers
#include
#include
void RandomChessLocation (int& x, int& y)
{
x = rand () % 8;
y = rand () % 8;
}
int main ()
{
srand (time (NULL));
int x, y;
for (int i=0; i<10; i++) {
RandomChessLocation (x, y);
printf ("\nCell X: %d --- Cell Y: %d", x, y);
}
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment