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 %f\n", i+1, y, t);
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
y
1 1.778598 -1.000000
2 1.725202 -0.960000
3 1.672650 -0.920000
4 1.621020 -0.880000
5 1.570396 -0.840000
6 1.520874 -0.800000
7 1.472559 -0.760000
8 1.425569 -0.720000
9 1.380030 -0.680000
10 1.336085 -0.640000
11 1.293887 -0.600000
12 1.253605 -0.560000
13 1.215421 -0.520000
14 1.179529 -0.480000
15 1.146134 -0.440000
16 1.115452 -0.400000
17 1.087700 -0.360000
18 1.063096 -0.320000
19 1.041853 -0.280000
20 1.024167 -0.240000
21 1.010214 -0.200000
22 1.000136 -0.160000
23 0.994040 -0.120000
24 0.200000 -0.080000
25 0.300000 -0.040000
26 0.400000 0.000000
27 0.500000 0.040000
28 0.600000 0.080000
29 0.700000 0.120000
30 0.800000 0.160000
31 0.900000 0.200000
32 1.000000 0.240000
33 1.100000 0.280000
34 1.200000 0.320000
35 1.300000 0.360000
36 1.400000 0.400000
37 1.500000 0.440000
38 1.600000 0.480000
39 1.422367 0.520000
40 1.457018 0.560000
41 1.493363 0.600000
42 1.531286 0.640000
43 1.570678 0.680000
44 1.611435 0.720000
45 1.653461 0.760000
46 1.696668 0.800000
47 1.740972 0.840000
48 1.786298 0.880000
49 1.832574 0.920000
50 1.879736 0.960000