constk

If_Else

Oct 16th, 2019
146
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <iostream>
  4. #include "math.h"
  5.  
  6. int main() {
  7. setlocale(0, "Russian");
  8. float x, y;
  9. printf("Введите x > ");
  10. scanf("%f", &x);
  11.  
  12. if (x >= -5 && x <= 9) {
  13. if (x <= -3) {
  14. y = (-x) + 3;
  15. }
  16. else {
  17. if (x <= 0) {
  18. y = sqrt(9 - x * x);
  19. }
  20. else {
  21. if (x <= 6) {
  22. y = (-x / 2) + 3;
  23. }
  24. else {
  25. y = x - 6;
  26. }
  27. }
  28. }
  29. printf("y(%2.2f) = %2.2f\n", x, y);
  30. }
  31. else {
  32. printf("Функция не определена для x = %2.2f\n", x);
  33. }
  34.  
  35. system("pause");
  36. return 0;
  37. }
RAW Paste Data