fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. /* f1(x) = (3x - 1)^2 / x^5 */
  5. double f1(double x) {
  6. return pow((3 * x - 1), 2) / pow(x, 5);
  7. }
  8.  
  9. /* f2(x) = (ln(sqrt(x+5)))^2 */
  10. double f2(double x) {
  11. return pow(log(sqrt(x + 5)), 2);
  12. }
  13.  
  14. /* f3(x) = cos(sqrt(1 + x^2)) */
  15. double f3(double x) {
  16. return cos(sqrt(1 + x * x));
  17. }
  18.  
  19.  
  20. double x, a, y;
  21.  
  22. printf("Введiть x: ");
  23. scanf("%lf", &x);
  24. printf("Введiть a: ");
  25. scanf("%lf", &a);
  26.  
  27. if (x <= 0) {
  28. y = f1(x);
  29. } else if (x <= a) {
  30. y = f2(x);
  31. } else {
  32. y = f3(x);
  33. }
  34.  
  35. printf("Результат: f = %.6f\n", y);
  36.  
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 5320KB
stdin
1
2
stdout
Введiть x: Введiть a: Результат: f = 0.802600