C++的简单程序

来源:百度知道 编辑:UC知道 时间:2024/05/27 13:52:40
#include<iostream.h>
void main(void)
{cout<<"Please enter 2 numbers:";
cin<<a<<b<<'\n';
int a,b,ab;
a=a-b;
b=x+b;
a=b-a;
ab=a/b;
cout<<"a="<<a<<",b"<<b<<'\n';
cout<<"ab"<<ab<<endl;
}
这个是那里错了,下面的是错误提示。
F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(4) : error C2065: 'a' : undeclared identifier
F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(4) : error C2676: binary '<<' : 'class istream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator
F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(4) : error C2065: 'b' : undeclared identifier
F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(7) : error C2065: 'x' : undeclared identifier
Error executing cl.exe.

F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(7) : error C2065: 'x' : undeclared identifier

a=a-b;
b=x+b; 你哪儿来的x? 这个是没有定义x

F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(4) : error C2065: 'a' : undeclared identifier
F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(4) : error C2065: 'b' : undeclared identifier

cin<<a<<b<<'\n';
int a,b,ab;在这里出错了 你先使用了后定义的 应该定义在先

F:\新建文件夹\myprojects4\p2_4\p2_4.cpp(4) : error C2676: binary '<<' : 'class istream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator

Error executing cl.exe.
这两个错误是你的文件运行错误 你的是2.0 还是 3.0 啊?2。0里面不能运行 必须在3.0里面 你的最后这个c1.exe这个错误是你的文件目录设置有错误!
你应该是个C 的初学者吧 首先先找人把你的软件给安装正确!
上面的问题都给你解释清楚了吧!

哎,你这个里面有很多的错误!
变量没有先定义就使用了,a.b.x都没有先定义!
还有就是cin和cout后面的<<,>>你都没