fork(1) download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6. double a = 2.5;
  7. double b = 0.4;
  8. double y;
  9.  
  10. double t_start = -1.0;
  11. double t_end = 1.0;
  12. int points = 50;
  13. printf("y\n");
  14. for (int i = 0; i < points; i++)
  15. {
  16. double t = t_start+((t_end-t_start)/(points))*i;
  17.  
  18. if (t<-0.1)
  19. {
  20. y = pow(a * t * t + b * sin(t) + 1, 0.5);
  21. }
  22.  
  23. else if (t >= -0.1 && t <= 0.5)
  24. {
  25. y = a * t + b;
  26. }
  27.  
  28. else
  29. {
  30. y = pow(a * t * t + b * cos(t) + 1, 0.5);
  31. }
  32.  
  33. printf("%d %f\n", y, i+1);
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
y
1 1.778598
2 1.725202
3 1.672650
4 1.621020
5 1.570396
6 1.520874
7 1.472559
8 1.425569
9 1.380030
10 1.336085
11 1.293887
12 1.253605
13 1.215421
14 1.179529
15 1.146134
16 1.115452
17 1.087700
18 1.063096
19 1.041853
20 1.024167
21 1.010214
22 1.000136
23 0.994040
24 0.200000
25 0.300000
26 0.400000
27 0.500000
28 0.600000
29 0.700000
30 0.800000
31 0.900000
32 1.000000
33 1.100000
34 1.200000
35 1.300000
36 1.400000
37 1.500000
38 1.600000
39 1.422367
40 1.457018
41 1.493363
42 1.531286
43 1.570678
44 1.611435
45 1.653461
46 1.696668
47 1.740972
48 1.786298
49 1.832574
50 1.879736