我编写了一个简单的c ++程序来计算二次方程。我用g ++在ubuntu linux上编译了它。
下面是代码:
#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端口。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句