Joshua Rutschmann 8 lat temu
rodzic
commit
681562e007
1 zmienionych plików z 21 dodań i 0 usunięć
  1. 21
    0
      hw4/simu3/randomtrace.c

+ 21
- 0
hw4/simu3/randomtrace.c Wyświetl plik

@@ -0,0 +1,21 @@
1
+#include <stdio.h>
2
+#include <stdlib.h>
3
+#include <time.h>
4
+
5
+int main(int argc, char* argv[]) {
6
+  srand(time(NULL));
7
+
8
+  if (argc != 3) {
9
+    printf("Usage: ./randomtrace <count> <size>\n");
10
+    return -1;
11
+  }
12
+
13
+  int i, r, s, t;
14
+  s = atoi(argv[1]);
15
+  t = atoi(argv[2]);
16
+  for (i = 0; i < s; i++) {
17
+    r = (int) ((rand() % t) + 1);
18
+    printf("%d ", r);
19
+  }
20
+  printf("\n");
21
+}

Ładowanie…
Anuluj
Zapisz