Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <cmath>
- #include <windows.h>
- void SetColor(int text, int background)
- {
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hStdOut, (WORD)((background << 4) | text));
- }
- double calc(double x){
- if (abs(x) <= 1){
- return(log(x));
- } else
- return(pow(x,3));
- }
- int main(){
- double x, sum=0, q=0, f;
- setlocale(0,"");
- cout<<"Вхідні дані:\n";
- 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);
- cout<<"dx=";SetColor(3,0);cout<<"1.0\n";SetColor(15,0);
- cout<<"y=ln(x), |x|<=1"<<endl;
- cout<<"y=x^3, |x|>1"<<endl;
- cout<<"S - сума непозитивних значень F\nQ - кількість непозитивних значень F\n";
- cout<<"\tx\t|\tF(x)\n________________________________\n";
- for (x=-1; x<=6; x++){
- f = calc(x);
- if (f<=0){
- sum += f;
- q++;
- }
- cout<<"\t"<<x<<"\t|\t"<<f<<endl;
- }
- cout<<"\tS = "<<sum<<"\tQ = "<<q<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement