C++ if条件

来源:百度知道 编辑:UC知道 时间:2024/06/09 04:18:59
#include "iostream.h"
int main()
{
int a,b;
cout<<"输入两个数";
cin>>a>>b;
if(a>b)
{
int temp;
temp=a;
a=b;
b=temp;
}
cout<<a<<" "<<b<<endl;
return 0;
}

如果输入15应该就显示15 如果输入65 就应该显示56

可是 输入之后就不显示了啊

也没有press any key

我刚开始学 不会。。

代码是对的
你首先需要输入2个数字,譬如15 65
之间要用空格隔开
然后按回车键就会有结果拉:
15 65
press any key to continue

在return 0;前加一行:
system("pause");

代码没错啊
你检查下其他有没有错
#include "iostream.h" 最好改#include <iostream.h>