Advertisement
R0M41K

parametr

Apr 1st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 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, sum=0, 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);cout<<"<=";SetColor(3,0);cout<<"6\n";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<<"S - сума непозитивних значень F\nQ - кількість непозитивних значень F\n";
  25. cout<<"\tx\t|\tF(x)\n________________________________\n";
  26. for (x=-1; x<=6; x++){
  27. f = calc(x);
  28. if (f<=0){
  29. sum += f;
  30. q++;
  31. }
  32. cout<<"\t"<<x<<"\t|\t"<<f<<endl;
  33. }
  34. cout<<"\tS = "<<sum<<"\tQ = "<<q<<endl;
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement