我写了一个简单的 C++ 程序来计算二次方程。我在 ubuntu linux 上用 g++ 编译了它。
顺便说一下代码:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a,b,c;
double x,x2;
cout<<"Give a: ";
cin>>a;
cout<<"Give b: ";
cin>>b;
cout <<"Give c: ";
cin>>c;
if (a==0)
{
if (b==0)
{
if (c==0)
{
cout<<"Solution indeterminable";
return 0;
}
else
{
cout<<"No solution";
return 0;
}
}
else
{
x=-c/b;
cout<<"The only root is x: "<<x;
return 0;
}
}
else
{
double b_sqr=b*b;
if (b_sqr>4*b*c)
{
cout<<"Complex roots: ";
return 0;
}
else if (b_sqr==4*b*c)
{
x=-b/(2*a);
cout<<"The only solution is x: "<<x;
return 0;
}
else
{
x=-b+(sqrt((b*b)-(4*a*c)))/(2*2);
x2=-b-(sqrt((b*b)-(4*a*c)))/(2*2);
cout<<"The first root is x1: "<<x;
cout<<"The first root is x2: "<<x2;
return 0;
}
}
}
现在,当我尝试在我的 x64 Windows 7 上运行它时,这就是我得到的:
不支持的 16 位应用程序:
由于与 64 位版本的 windows 不兼容,程序或功能 equation.exe 无法启动或运行。请联系软件供应商询问是否有 64 位 Windows 兼容版本可用
好吧,我是作者,我编写了 simpe c++ 来对其进行编码。这个兼容性问题是怎么回事?
我如何设法在 Windows 7 x64 上运行它? 谢谢!
最佳答案
Windows 无法运行针对其他操作系统的可执行文件。您需要使用面向 Windows 的编译器重新编译。例如 mingw 可能是 Windows 使用最广泛的 GCC 端口。
关于c++ 可执行文件不能在 windows 7 中运行 - 64 位不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23035472/