Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "iostream"
- #include "conio.h"
- #include "locale.h"
- #include "math.h"
- using namespace std;
- int main() {
- setlocale(0,"Russian");
- double xn, xk, a, b, c, f=0, dx;
- cout << "введите Xнач: "; cin >> xn;
- cout << "введите Xконеч: "; cin >> xk;
- cout << "введите dX: "; cin >> dx;
- cout << "введите a: "; cin >> a;
- cout << "введите b: "; cin >> b;
- cout << "введите c: "; cin >> c;
- double x=xn;
- while(x<=xk)
- {
- if(x<0 && b!=0)
- f=a*x*x+b;
- else if(x>0 && b==0) {
- if(fabs(c)<1e-5)
- f=0;
- else
- f=x/c;
- } else {
- if(fabs(x-c)<1e-5)
- f=0;
- else
- f=(x-a)/(x-c);
- }
- if(~((int)a |(int)b)&&((int)a|(int)c)==0)
- f=(int)f;
- if(fabs(x)<1e-5)
- x=0;
- cout << "\n x=" << x;
- if(fabs(x-c)<1e-5 || fabs(c)<1e-5) {
- cout << " \t делить на ноль нельзя";
- } else {
- if(fabs(f)<1e-5)
- f=0;
- cout << " \t f=" << f;
- }
- x=x+dx;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement