fork(3) download
  1. #include <cstdlib>
  2. #include <cmath>
  3. #include <iostream>
  4.  
  5. constexpr float a = -3.14f;
  6. constexpr float b = 3.14f;
  7. constexpr float s = 0.1f;
  8. constexpr int n = std::round(std::abs(a - b) / s);
  9.  
  10. auto main() -> int
  11. {
  12. std::cout.precision(15);
  13.  
  14. for (int i = 0; i < n; ++i)
  15. {
  16. float t = static_cast<float>(i) / static_cast<float>(n - 1);
  17. std::cout << i << ": " << (1.0f - t) * a + t * b << "\n";
  18. }
  19. }
Success #stdin #stdout 0s 4288KB
stdin
Standard input is empty
stdout
0: -3.14000010490417
1: -3.03870987892151
2: -2.93741965293884
3: -2.83612895011902
4: -2.73483872413635
5: -2.63354849815369
6: -2.53225803375244
7: -2.43096780776978
8: -2.32967734336853
9: -2.22838711738586
10: -2.1270968914032
11: -2.02580666542053
12: -1.92451632022858
13: -1.82322597503662
14: -1.72193551063538
15: -1.62064528465271
16: -1.51935505867004
17: -1.4180645942688
18: -1.31677436828613
19: -1.21548390388489
20: -1.11419367790222
21: -1.01290309429169
22: -0.911612868309021
23: -0.810322523117065
24: -0.709032297134399
25: -0.607741951942444
26: -0.506451725959778
27: -0.405161380767822
28: -0.303871154785156
29: -0.202580571174622
30: -0.101290345191956
31: 0
32: 0.101290225982666
33: 0.20258092880249
34: 0.303871154785156
35: 0.405161380767822
36: 0.506451606750488
37: 0.607742071151733
38: 0.709032297134399
39: 0.810322523117065
40: 0.911612749099731
41: 1.01290345191956
42: 1.11419367790222
43: 1.21548390388489
44: 1.31677412986755
45: 1.41806483268738
46: 1.51935505867004
47: 1.62064528465271
48: 1.72193551063538
49: 1.82322609424591
50: 1.92451632022858
51: 2.02580642700195
52: 2.12709665298462
53: 2.22838711738586
54: 2.32967734336853
55: 2.4309675693512
56: 2.53225779533386
57: 2.63354849815369
58: 2.73483872413635
59: 2.83612895011902
60: 2.93741917610168
61: 3.03870987892151
62: 3.14000010490417