Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- static inline double r(double beg, double end) {
- return (rand() + 1.) / (RAND_MAX + 2.) * (end - beg) + beg;
- }
- static inline void write_random(FILE *out, unsigned int upper) {
- int n = rand() % upper;
- for (int i = 0; i < n; ++i) { fprintf(out, "%f\n", r(-10., 10.)); }
- }
- int main(void) {
- srand(time(NULL));
- FILE *out = fopen("random.txt", "w");
- write_random(out, 100);
- fclose(out);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement