-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand.cpp
More file actions
21 lines (21 loc) · 955 Bytes
/
rand.cpp
File metadata and controls
21 lines (21 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdlib.h>
#include <stdio.h>
int main() {
FILE *f;
f = fopen("data.txt","w");
for(int i = 0; i < 30; i++) {
if(i % 8 == 0||i % 8 == 1||i % 8 == 3||i % 8 == 6) fprintf(f,"%f\n", rand()*20./RAND_MAX);
if(i % 8 == 2||i % 8 == 4||i % 8 == 5||i % 8 == 7) fprintf(f,"%f\n", rand()*-20./RAND_MAX);
} fclose(f);
f = fopen("data1.txt","w");
for(int i = 0; i < 40; i++) {
if(i % 8 == 0||i % 8 == 1||i % 8 == 3||i % 8 == 6) fprintf(f,"%f\n", rand()*20./RAND_MAX);
if(i % 8 == 2||i % 8 == 4||i % 8 == 5||i % 8 == 7) fprintf(f,"%f\n", rand()*-20./RAND_MAX);
} fclose(f);
f = fopen("data2.txt","w");
for(int i = 0; i < 32; i++) {
if(i % 8 == 0||i % 8 == 1||i % 8 == 3||i % 8 == 6) fprintf(f,"%f\n", rand()*20./RAND_MAX);
if(i % 8 == 2||i % 8 == 4||i % 8 == 5||i % 8 == 7) fprintf(f,"%f\n", rand()*-20./RAND_MAX);
} fclose(f);
return 0;
}