Модул…без използване на fabs.

11 11 2010

Задача . Да се състави програма, която по реално число x и без да използва функцията fabs пресмята стойноста на функцията

f(x) = | |3 – x| – |-x2 + x + 2|| .

Една програма, която решава задачата е следна:

#include <iostream>
#include <cmath>
using namespace std;
int main(){

 cout<<"x=";double x;cin>>x;

 double y;

 y= sqrt((( sqrt((3-x)*(3-x))) - sqrt((-x*x + x + 2)*(-x*x + x + 2)))*(( sqrt((3-x)*(3-x))) - sqrt((-x*x + x + 2)*(-x*x + x + 2))));

 cout<<"y:"<<y<<endl;

return 0;}

~S.K.G~


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: