intgen.c 500 B

1234567891011121314151617181920212223242526
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #define MAXVALUE 100000
  6. int main(int argc, char * * argv)
  7. {
  8. if (argc < 2)
  9. {
  10. printf("need a number\n");
  11. return EXIT_FAILURE;
  12. }
  13. int num = (int) strtol(argv[1], NULL, 10);
  14. if (num <= 0)
  15. {
  16. printf("need a positive number\n");
  17. return EXIT_FAILURE;
  18. }
  19. srand(time(NULL));
  20. while (num > 0)
  21. {
  22. printf("%d\n", rand() % MAXVALUE);
  23. num --;
  24. }
  25. return EXIT_SUCCESS;
  26. }