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(abs(x)));
- } else
- return(pow(x,3));
- }
- int main(){
- double x = -2, 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<<"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<<"Виконувати поки cos(f)>cos(x) \n";
- cout<<"\tx\t|\tF(x)\n________________________________\n";
- do{
- x++;
- f = calc(x);
- if (f<0) q++;
- cout<<"\t"<<x<<"\t|\t"<<f<<endl;
- }while(cos(f)>cos(x));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement