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 + i * (t_end - t_start) / (points - 1);
  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("%f\n", y);
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
y
1.778598
1.724121
1.670524
1.617890
1.566310
1.515887
1.466732
1.418971
1.372742
1.328198
1.285505
1.244844
1.206411
1.170417
1.137082
1.106635
1.079309
1.055335
1.034933
1.018305
1.005626
0.997031
0.992615
0.246939
0.348980
0.451020
0.553061
0.655102
0.757143
0.859184
0.961224
1.063265
1.165306
1.267347
1.369388
1.471429
1.573469
1.414153
1.449088
1.485814
1.524208
1.564151
1.605533
1.648250
1.692208
1.737317
1.783495
1.830668
1.878765
1.927724