暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

randomtrace.c 444B

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