Advertisement
R0M41K

peredumova

Apr 2nd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 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(x));
  13. } else
  14. return(pow(x,3));
  15. }
  16. int main(){
  17. double x = -1, 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<<"Виконувати поки кількість (F < 0) менше 10 \n";
  25. cout<<"\tx\t|\tF(x)\n________________________________\n";
  26. while (q<10){
  27.  
  28. f = calc(x);
  29. if (f<0) q++;
  30. cout<<"\t"<<x<<"\t|\t"<<f<<endl;
  31. cout<<"\tQ = "<<q<<endl;
  32. x++;
  33. }
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement