Tính giá trị Z
If x^3 + 2x^2 + 4x - 6 với x>=0
If x^3 - 7x với x < 0
Input: 3
Output: 51
Input: -2
Output: 6
Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long x;
cin>>x;
if(x >= 0)
cout<<x*x*x+2*x*x+4*x-6;
if(x < 0)
cout<<x*x*x-7*x;
return 0;
}