/* Vladimir Poplavskij. Wykladowca * ----------------- * Random. * ----------------- 2022-12-02 */ #include <stdio.h> #include <stdlib.h> #include <errno.h> int main(void) { FILE *fptr; fptr = fopen("random.dat", "w"); int n = 0, i = 0; srand(( unsigned )time(NULL)); if (fptr != NULL) { printf("File created successfully!\n"); } else { printf("Failed to create the file.\n"); return -1; } do { printf("Wprowadzenie n. Musi byc != 0 \n"); scanf("%d", &n); } while (n <= 0); t = clock(); while (i < n) { int j = 1 + rand() % 138573; printf("%d \n", j); fprintf(fptr, "%d\n", j); i = i + 1; } fclose(fptr); return 0; }