Advertisement
R0M41K

postumova

Apr 2nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include <cmath>
  4. #include <windows.h>
  5. void SetColor(int text, int background)
  6. {
  7. HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  8. SetConsoleTextAttribute(hStdOut, (WORD)((background << 4) | text));
  9. }
  10. double calc(double x){
  11. if (abs(x) <= 1){
  12. return(log(abs(x)));
  13. } else
  14. return(pow(x,3));
  15. }
  16. int main(){
  17. double x = -2, q=0, f;
  18. setlocale(0,"");
  19. cout<<"Вхідні дані:\n";
  20. SetColor(3,0);cout<<"-1";SetColor(15,0);cout<<"<=";SetColor(3,0);cout<<"x";SetColor(15,0);
  21. cout<<"dx=";SetColor(3,0);cout<<"1.0\n";SetColor(15,0);
  22. cout<<"y=ln(x), |x|<=1"<<endl;
  23. cout<<"y=x^3, |x|>1"<<endl;
  24. cout<<"Виконувати поки cos(f)>cos(x) \n";
  25. cout<<"\tx\t|\tF(x)\n________________________________\n";
  26. do{
  27. x++;
  28. f = calc(x);
  29. if (f<0) q++;
  30. cout<<"\t"<<x<<"\t|\t"<<f<<endl;
  31. }while(cos(f)>cos(x));
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement