/* ex1109.c */
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned seed;
int r,a,b;
printf("Input a random number seed: ");
scanf("%u",&seed);
srand(seed);
for(a=1;a<=20;a++)
{
for(b=1;b<=5;b++)
{
r=rand();
printf("%d\t",r);
}
putchar('\n');
}
return(0);
}
output:
Input a random number seed: -13
32764 31830 18380 17294 5837
26285 671 4804 25175 12233
7776 27528 8249 14555 26951
19902 20759 16133 11965 3771
3646 27247 23070 252 25227
21399 14014 17432 10889 29416
28970 20724 16345 11919 15792
5686 29655 31370 18465 14588
7546 16129 20693 19917 15996
30938 6896 7632 955 18568
4068 19515 9440 25379 15415
28687 26430 6590 2439 30211
18429 27381 22987 24253 4471
21189 26587 11592 24546 19617
4403 6595 22832 15297 27891
23638 7219 11710 21547 9323
11013 11100 16214 4122 21671
2982 7460 14308 25064 32065
1661 8869 2440 14842 29634
13764 28574 6305 22358 30125
Process returned 0 (0x0) execution time : 3.405 s
Press any key to continue.
Tidak ada komentar:
Posting Komentar