注册 登录
编程论坛 C++教室

代码没错,为什么编辑器老是提错

xmt007 发布于 2007-08-10 08:47, 747 次点击
#include <iostream>
using namespace std;
int max (int i,int j)
{
if(i>=j)
return i;
else return j;
}
int main ()
{
cout << "输入 i,j:";
int i,j;
cin>>i>>j;
cout << "最大数是:" << max(i,j) <<endl;
system("pause")
}






C:\Documents and Settings\Administrator\桌面\include\iostream.cpp(16) : error C2143: syntax error : missing ';' before '}'
8 回复
#2
blueboy820062007-08-10 08:59
以下是引用xmt007在2007-8-10 8:47:20的发言:
system("pause")

最后一行没写分号啊

#3
xmt0072007-08-10 09:13

刚才忘记打上。。。不过还是运行错误 真不知道我的编辑器是不是给我编坏了,在别人的机器运行可以成功的噢

#4
blueboy820062007-08-10 09:35

是啊,我运行了,发现没什么问题啊

#5
stephenliu2007-08-10 22:00
回复:(xmt007)代码没错,为什么编辑器老是提错
少了 #include &lt;math.h&gt;
#6
terisevend2007-08-11 01:46
[QUOTE]

回复:(xmt007)代码没错,为什么编辑器老是提错

少了 #include <math.h>
[/QUOTE]

to stephenliu: LZ的程序没有调试数学函数...所以不加上 #include <math.h> 业可以吧...

to LZ: 可能是因为main的类型为int, 而代码中, main却没有返回值的缘故吧...
#7
networkwjh2007-08-11 22:31

不要放桌面上不就行了吗?

#8
wxt3352007-08-11 22:50
#include <iostream>
using namespace std;
int max (int i,int j)
{
if(i>=j)
return i;
else return j;
}
int main ()
{
cout << "输入 i,j:";
int i,j;
cin>>i>>j;
cout << "最大数是:" << max(i,j) <<endl;
system("pause");
}
#9
圆圆的鸟蛋2007-08-11 23:29
#include <iostream>
using namespace std;

int max (int i,int j)
{
if(i>=j)
return i;
else
return j;
}

int main ()
{
cout << "输入 i,j:";
int i,j;
cin>>i>>j;
cout << "最大数是:" << max(i,j) <<endl;
system("pause");

return 0 ; //加上这句
}

你的main函数是int类型,所以一定要有返回值。。
1