#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
int main()
{
float xstart = -2, xfinal = 2, h = 0.5;
float t, y;
cout << "X start = -2" << endl;
cout << "X final = 2" << endl;
cout << "step = 0.5" << endl << endl;
for (float x = xstart; x <= xfinal; x+= h)
{
t= sqrt(pow(sin(x),2))/sqrt(x - 4);
y= sqrt(2 * t + x);
cout << x << " | " << t << " | " << y << endl;
}
cout << endl;
}
此输出吨和y变量楠。我对如何解决这个问题没有想法。代码仅仅是问题的例子,除了修复工具之外,不需要做其他任何事情。楠在C + +初学者
负数的平方根是NAN。 – tkausl
这里的问题不是C++。这里的问题是基本的数学。 –
你怎么看'的sqrt(POW(SIN(-2),2))/开方(-2 -4)'是一个浮点值?我相当肯定'float'不能代表'-0.321 * i' – CollinD