Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include "conio.h"
  4. #include "locale.h"
  5. #include "math.h"
  6. using namespace std;
  7.  
  8. int main() {
  9. setlocale(0,"Russian");
  10. double xn, xk, a, b, c, f=0, dx;
  11.  
  12. cout << "введите Xнач: "; cin >> xn;
  13. cout << "введите Xконеч: "; cin >> xk;
  14. cout << "введите dX: "; cin >> dx;
  15. cout << "введите a: "; cin >> a;
  16. cout << "введите b: "; cin >> b;
  17. cout << "введите c: "; cin >> c;
  18. double x=xn;
  19. while(x<=xk)
  20. {
  21. if(x<0 && b!=0)
  22. f=a*x*x+b;
  23. else if(x>0 && b==0) {
  24. if(fabs(c)<1e-5)
  25. f=0;
  26. else
  27. f=x/c;
  28. } else {
  29. if(fabs(x-c)<1e-5)
  30. f=0;
  31. else
  32. f=(x-a)/(x-c);
  33. }
  34. if(~((int)a |(int)b)&&((int)a|(int)c)==0)
  35. f=(int)f;
  36. if(fabs(x)<1e-5)
  37. x=0;
  38. cout << "\n x=" << x;
  39. if(fabs(x-c)<1e-5 || fabs(c)<1e-5) {
  40. cout << " \t делить на ноль нельзя";
  41. } else {
  42. if(fabs(f)<1e-5)
  43. f=0;
  44. cout << " \t f=" << f;
  45. }
  46. x=x+dx;
  47. }
  48. system("pause");
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement