Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "iostream"
- #include "math.h"
- #include "conio.h"
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- float A, B, DEL, x, F, a, b, c;
- int i = 1; F = 0.0;
- cout << "ВВедите точку A: "; cin >> A;
- do
- {
- cout << "Введите точку B (B > A): "; cin >> B;
- } while (A > B);
- cout << "Введие шаг: "; cin >> DEL;
- cout << "Введите коэфициент a: "; cin >> a;
- cout << "Введите коэфициент b: "; cin >> b;
- cout << "Введите коэфициент c: "; cin >> c;
- cout << "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" << endl << "Цикл for:" << endl;
- for (x = A; (A <= x) && (x <= B); x = +DEL)
- {
- if ((x+c<0) && ((a) != 0))
- {
- cout << endl << "F = (x - a) / (x - c): \t";
- cout << "При x =" << x << "\tF" << i << "=" << F;
- F = (x - a) / (x - c);
- i++;
- }
- else
- {
- cout << "При x =" << x << "\tF" << i << "=" << F;
- F = x*c + x*b
- i++;
- }
- }
- i = 1; F = 0.0; x = A;
- cout << endl << "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" << endl << "Цикл while:" << endl;
- while ((A <= x) && (x <= B))
- {
- if (((x+c<0) && (a)) != 0)
- {
- cout << endl << "F = -a*x*x*x-b: \t";
- cout << "При x =" << x << "\tF" << i << "=" << F;
- i++;
- }
- else if ((x+c>0) && ((a) == 0))
- {
- cout << endl << "F = (x - a) / (x - c): \t";
- cout << "При x =" << x << "\tF" << i << "=" << F;
- F = (x - a) / (x - c);
- i++;
- }
- else
- {
- cout << endl << "F = x * c + x *b \t";
- cout << "При x =" << x << "\tF" << i << "=" << F;
- F = x * c + x * b;
- i++;
- }
- x += DEL;
- }
- i = 1; F = 0.0; x = A;
- cout << endl << "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" << endl << "Цикл while:" << endl;
- do
- {
- if ((x+c<0) && ((a) != 0))
- {
- cout << endl << "F = -a * x * x * x - b: \t";
- cout << "При x =" << x << "\tF" << i << "=" << F;
- F = -a * x * x * x - b ;
- i++;
- }
- else if (((x+c > 0) && (a)) == 0)
- {
- cout << endl << "F = (x - a) / (x - c): \t";
- cout << "При x =" << x << "\tF" << i << "=" << F;
- F = (x - a) / (x - c);
- i++;
- }
- else
- {
- cout << endl << "F = x * c + x * b \t";
- cout << "При x =" << x << "\tF" << i << "=" << F;
- F = x * c + x * b;
- i++;
- }
- x += DEL;
- } while ((A <= x) && (x <= B));
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement