为什么我没有得到正确的结果?为什么此代码会产生奇怪的意外输出?
我没有得到px的正确输出,虽然我把它命名为double,但我得到了一些令人害怕的数字文本混搭。
#include <iostream>
using namespace std;
int main(){
double a = 0; double b = 0; double c = 0; double x = 0;
cout << "Welcome to Lytis! \nPlease enter a:";
cin >> a;
cout << "Please enter b:";
cin >> b;
cout << "Please enter c:";
cin >> c;
if (a != 0){
double d = (b*b) - (4 * a * c);
}
f (d == 0){
double x = -(b)/(2 * a);
double *px = &x;
cout << "The only solution is x=" << px;
cin.get();
}
我错过了什么?
#为什么#are#你使用#using#哈希标签? – Mehrdad
我想你得到一个十六进制数字,你打印指针的地址。阅读指针,你会找到你的解决方案。 – AxelOmega
您缺少部分实际的代码。此代码不能编译,所以它*没有行为*。如果您没有向我们展示您的实际代码,我们无法告诉您程序有什么问题。将您的实际代码复制并粘贴到问题中。 –