diff options
| author | Franklin Wei <me@fwei.tk> | 2018-11-12 20:35:57 -0500 |
|---|---|---|
| committer | Franklin Wei <me@fwei.tk> | 2018-11-12 20:35:57 -0500 |
| commit | 9307fa69feed3a72927858538fbed9546c0fd451 (patch) | |
| tree | 2be1fe72e022c7e8e22f206b5fa434b1603f43d5 /genrand.c | |
| parent | bb87e0d168d01ca4a02d6d438f165e6f20bebbf0 (diff) | |
| download | circgraph-9307fa69feed3a72927858538fbed9546c0fd451.zip circgraph-9307fa69feed3a72927858538fbed9546c0fd451.tar.gz circgraph-9307fa69feed3a72927858538fbed9546c0fd451.tar.bz2 circgraph-9307fa69feed3a72927858538fbed9546c0fd451.tar.xz | |
Command-line parsing and miscellaneous fixes
Diffstat (limited to 'genrand.c')
| -rw-r--r-- | genrand.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -3,26 +3,27 @@ int main(int argc, char *argv[]) { - if(argc != 2) + if(argc != 3) { - fprintf(stderr, "Usage: %s EDGES\n", argv[0]); + fprintf(stderr, "Usage: %s MAXNODES EDGES\n", argv[0]); return 1; } - int edges = atoi(argv[1]); + int maxnodes = atoi(argv[1]); + int edges = atoi(argv[2]); srand(time(0)); - printf("a b\n"); - printf("a b 1\n"); + printf("1 2\n"); + printf("1 2 1\n"); for(int i = 0; i < edges; i++) { - char a, b; - a = rand() % 26; + int a, b; + a = rand() % maxnodes; do { - b = rand() % 26; + b = rand() % maxnodes; } while(b == a); - printf("%c %c 1\n", 'a' + a, 'a' + b); + printf("%d %d 1\n", a, b); } } |