-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (26 loc) · 701 Bytes
/
main.cpp
File metadata and controls
36 lines (26 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(nullptr));
int samples = 20;
double* temperatures = new double[samples];
// simulates sensor data
for (int i = 0; i < samples; i++) {
temperatures[i] = 20 + (rand() % 1500) / 100.0;
}
ofstream file("data.json");
file << "{\n \"temperatures\": [\n";
for (int i = 0; i < samples; i++) {
file << " " << temperatures[i];
if (i < samples - 1) file << ",";
file << "\n";
}
file << " ]\n}";
file.close();
delete[] temperatures;
cout << "Data successfully generated.\n";
return 0;
}