Start an editor and enter the following code:
#include
#define MAX 10
int a[MAX];
int rand_seed=10;
int rand() /* from K&R - returns random number between 0 and 32767.*/
{
rand_seed = rand_seed * 1103515245 +12345;
return (unsigned int)(rand_seed / 65536) % 32768;
}
void main()
{
int i,t,x,y;
/* fill array */
for (i=0; i < MAX; i++)
{
a[i]=rand();
printf("%d\n",a[i]);
}
/* more stuff will go here in a minute */
}
#include
#define MAX 10
int a[MAX];
int rand_seed=10;
int rand() /* from K&R - returns random number between 0 and 32767.*/
{
rand_seed = rand_seed * 1103515245 +12345;
return (unsigned int)(rand_seed / 65536) % 32768;
}
void main()
{
int i,t,x,y;
/* fill array */
for (i=0; i < MAX; i++)
{
a[i]=rand();
printf("%d\n",a[i]);
}
/* more stuff will go here in a minute */
}
No comments:
Post a Comment