Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "iostream"
  3. #include "math.h"
  4. #include "conio.h"
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. setlocale(LC_ALL, "Russian");
  11.  
  12. float A, B, DEL, x, F, a, b, c;
  13. int i = 1; F = 0.0;
  14.  
  15. cout << "ВВедите точку A: "; cin >> A;
  16. do
  17. {
  18. cout << "Введите точку B (B > A): "; cin >> B;
  19. } while (A > B);
  20. cout << "Введие шаг: "; cin >> DEL;
  21. cout << "Введите коэфициент a: "; cin >> a;
  22. cout << "Введите коэфициент b: "; cin >> b;
  23. cout << "Введите коэфициент c: "; cin >> c;
  24.  
  25. cout << "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" << endl << "Цикл for:" << endl;
  26. for (x = A; (A <= x) && (x <= B); x = +DEL)
  27. {
  28. if ((x+c<0) && ((a) != 0))
  29. {
  30. cout << endl << "F = (x - a) / (x - c): \t";
  31. cout << "При x =" << x << "\tF" << i << "=" << F;
  32. F = (x - a) / (x - c);
  33. i++;
  34. }
  35. else
  36. {
  37. cout << "При x =" << x << "\tF" << i << "=" << F;
  38. F = x*c + x*b
  39. i++;
  40. }
  41. }
  42.  
  43. i = 1; F = 0.0; x = A;
  44. cout << endl << "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" << endl << "Цикл while:" << endl;
  45. while ((A <= x) && (x <= B))
  46. {
  47. if (((x+c<0) && (a)) != 0)
  48. {
  49. cout << endl << "F = -a*x*x*x-b: \t";
  50. cout << "При x =" << x << "\tF" << i << "=" << F;
  51. i++;
  52. }
  53. else if ((x+c>0) && ((a) == 0))
  54. {
  55. cout << endl << "F = (x - a) / (x - c): \t";
  56. cout << "При x =" << x << "\tF" << i << "=" << F;
  57. F = (x - a) / (x - c);
  58. i++;
  59. }
  60. else
  61. {
  62. cout << endl << "F = x * c + x *b \t";
  63. cout << "При x =" << x << "\tF" << i << "=" << F;
  64. F = x * c + x * b;
  65. i++;
  66. }
  67. x += DEL;
  68. }
  69. i = 1; F = 0.0; x = A;
  70. cout << endl << "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" << endl << "Цикл while:" << endl;
  71. do
  72. {
  73. if ((x+c<0) && ((a) != 0))
  74. {
  75. cout << endl << "F = -a * x * x * x - b: \t";
  76. cout << "При x =" << x << "\tF" << i << "=" << F;
  77. F = -a * x * x * x - b ;
  78. i++;
  79. }
  80. else if (((x+c > 0) && (a)) == 0)
  81. {
  82. cout << endl << "F = (x - a) / (x - c): \t";
  83. cout << "При x =" << x << "\tF" << i << "=" << F;
  84. F = (x - a) / (x - c);
  85. i++;
  86. }
  87. else
  88. {
  89. cout << endl << "F = x * c + x * b \t";
  90. cout << "При x =" << x << "\tF" << i << "=" << F;
  91. F = x * c + x * b;
  92. i++;
  93. }
  94. x += DEL;
  95. } while ((A <= x) && (x <= B));
  96. _getch();
  97. return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement