-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy paththink.cpp
More file actions
31 lines (26 loc) · 849 Bytes
/
think.cpp
File metadata and controls
31 lines (26 loc) · 849 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
#include <iostream>
#include <chrono>
#include <thread>
#include <cmath>
#include <cassert>
void hardcore_computation(double p, double q) {
// Your big number crunching work should go here.
// Instead we calculate some fake result.
std::this_thread::sleep_for(std::chrono::seconds(2));
const double result = std::sin(p + 2*q);
// Output the result.
std::cout <<
"{ \"params\":" "\n"
" { \"p\": " << p << "," "\n"
" \"q\": " << q << " }," "\n"
" \"result\": " << result << " }" "\n";
}
int main(int argc, const char **argv) {
// Retrieve parameters for this run.
assert(argc > 2);
const double p = std::stod(argv[1]);
const double q = std::stod(argv[2]);
// Start the computation.
hardcore_computation(p, q);
return 0;
}