Автор: артем111 (06.11.2010 в 15:36)
только начал изучать С++
программа выдает неправильное решение
y=x*x+x-1
f(x,y)=
y*y*y-1, при abs(y)<=1
при 1<=abs(y)<=2
5/8*y-1, при abs(y)>2
код программы
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include<iostream>
#include<math.h>
using namespace std;
int _tmain()
{
double f, x, y;
cout << " Vvedite x = ";
cin >> x;
y = x*x+x-1;
if (abs(y)<=1)
{
f=pow(y,3)-1;
cout<< "\n f="<<f;
}
if (abs(y)>=1 && abs(y)<=2)
{
f=2*y-1;
cout<< "\n f="<<f;
}
else
f=(5/8)*y-1;
cout << "\n f= "<< f;
getch ();
return 0;
}