c++的,帮忙看下哪里错了啊??

来源:百度知道 编辑:UC知道 时间:2024/07/03 23:00:14
#include<iostream.h>
main(int a, int b)
{
a=2;
b=4;
if(a<b)
{
cout<<"yes";
}
else()
{
cout<<"no";
}
}

去掉else后面的括号~!
#include<iostream.h>
main(int a, int b)
{
a=2;
b=4;
if(a<b)
{
cout<<"yes";
}
else
{
cout<<"no";
}
}

#include<iostream.h>
int main()
{
int a=2;
int b=4;
if(a<b)
cout<<"yes";
else
cout<<"no";
return 0;
}

去掉else后面的一对小括号就行

if后面有小括号是因为if需要写明条件,而else的条件就是与if相反,无需在写

另外少些输入输出需要的头文件

#include<iostream.h>
using namespace std; //输入输出需要用到的头文件

int main(int a, int b) // C++需要返回类型
{
a=2;
b=4;
if(a<b)
{
cout<<"yes";
}
else