完成此任务:
#include <iostream>
#include <clocale>
#include <math.h>
using namespace std;
int main()
{
using std::setlocale;
setlocale (LC_ALL,"");
double x, y, z, a, b, c, s;
cout << "Enter x: ";
cin >> x;
cout << "Enter y: ";
cin >> y;
cout << "Enter z:";
cin >> z;
a = sqrt(10*(pow(x,1/3)*(x,y+2)));
b = pow(asin(z),2);
c = fabs(x-y);
s = a*(b-c);
cout << "Result s = " << s << endl;
return 0;
}
不知道为什么显示的结果是NaN。能否请你帮忙?我的代码在上面。
添加的样本:
答案 0 :(得分:0)
您在这里:
#include <iostream>
#include <clocale>
#include <cmath>
using namespace std; //to simplify code, you shouldnt be using this
int main()
{
double x = 16.55*pow(10,-3);
double y = -2.75;
double z = 0.15;
double h = 1.0/3.0;
double s = sqrt(10*(pow(x,h)+pow(x,y+2)))*(pow(asin(z),2)-abs(x-y));
cout<<s;
}
就像山姆提到的那样,1/3似乎不是。在这种状态下,它被计算为一个int,结果为0。