编了一个控制台程序,在vc++6.0里可以用,但是直接打开编译的.exe文件就不行!!

来源:百度知道 编辑:UC知道 时间:2024/05/18 02:27:06
编了一个控制台程序,在vc++6.0里可以用,但是直接打开编译的.exe文件就总是在输入数字结束后退出,没有显示结果,请问这是怎么回事??是不是只能在vc++环境里运行阿??
源文件:
#include "stdafx.h"
#include "iostream.h"
#include "math.h"
int main()
{double x1,y1,x2,y2,a,b,angle;
cout<<"input the first point x1=";
cin>>x1;
cout<<"input the first point y1=";
cin>>y1;
cout<<"input the second point x2=";
cin>>x2;
cout<<"input the second point y2=";
cin>>y2;
a=abs(x1-x2);
b=abs(y1-y2);
angle=atan(b/a);
cout<<"a="<<a<<"\n";
cout<<"b="<<b<<"\n";
cout<<"angle="<<angle<<"\n";
return 0;

}
各位高手多谢拉!!!!!

命令行的.exe文件只能在命令行模式下单独运行.你把这个文件放在c盘的目录下,假设你的这个文件名叫1.exe
点开始 运行 输入cmd 进入dos,然后在C:\Documents and Settings\你的用户名>后面输入 cd\ 进入c盘的目录 C:\> 在这个后面输入 1.exe即可。

把你的代码改成这样啊 就行了啊

#include "stdafx.h"
#include "iostream.h"
#include "math.h"
int main()
{double x1,y1,x2,y2,a,b,angle;
cout<<"input the first point x1=";
cin>>x1;
cout<<"input the first point y1=";
cin>>y1;
cout<<"input the second point x2=";
cin>>x2;
cout<<"input the second point y2=";
cin>>y2;
a=abs(x1-x2);
b=abs(y1-y2);
angle=atan(b/a);
cout<<"a="<<a<<"\n";
cout<<"b="<<b<<"\n";
cout<<"angle="<<angle<<"\n";

getchar();//以后遇到这样的问