diff options
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); } } |