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 = -1, 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<<"Виконувати поки кількість (F < 0) менше 10 \n";
- cout<<"\tx\t|\tF(x)\n________________________________\n";
- while (q<10){
- f = calc(x);
- if (f<0) q++;
- cout<<"\t"<<x<<"\t|\t"<<f<<endl;
- cout<<"\tQ = "<<q<<endl;
- x++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement