-5
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;

void main() {
float y;
int x;
cout<<"Jep vleren e x-it:"<<endl;
cin>>x;
if (x>=1)
{
    y=(x^3 - 2*x)/(1+x^2);
    cout<<y<<endl;
}
if ((x>-1)&&(x<1))
{
    y = sqrt(1+x^2);
    cout<<y<<endl;
}
if (x<=-1) 
{
    y=x/(1+x^2);
    cout<<y<<endl;
}
_getch();
}

x に基づいて y の値を計算する必要があります。しかし、何か問題があります。入力する- 3と、 と表示されます0。なんで?

4

1 に答える 1

2

^ XOR演算子を使用しています。MSDNを参照してください。pow関数を使用しましたか?

于 2012-11-09T01:19:15.803 に答える