forked from The-OpenROAD-Project-Attic/flute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand-pts.c
More file actions
executable file
·36 lines (33 loc) · 1.13 KB
/
rand-pts.c
File metadata and controls
executable file
·36 lines (33 loc) · 1.13 KB
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
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int ac, char *av[])
{
int d=10, tmp, i;
int PNUM = 0;
for (i=1; i<ac; i++) {
if (strcmp(av[i], "-r")==0) // random
srandom((int) getpid());
else if (strncmp(av[i], "-s", 2)==0) // set random seed
srandom(atoi(av[i]+2));
else if (strcmp(av[i], "-n")==0) // print # of points first
PNUM=1;
else if (sscanf(av[i], "%d", &tmp)) // set # of points
d = tmp;
else {
printf("Usage: %s [-r] [-s<S>] [-n] [<D>]\n", av[0]);
printf(" Output <D> random points ");
printf("as <D> lines of coordinate pairs.\n");
printf(" Default <D> is 10.\n");
printf(" -r\t Randomize. Use getpid() as seed.\n");
printf(" -s<S>\t Set random seed to <S>.\n");
printf(" -n\t Write <D> first before the random points.\n");
exit(-1);
}
}
if (PNUM)
printf("%d\n", d);
for (i=1; i<=d; i++)
printf("%4d %4d\n", (int) random()%10000, (int) random()%10000);
}