unexpected end of file found ??!!

来源:百度知道 编辑:UC知道 时间:2024/05/26 18:11:54
#include "stdafx.h"
#include <iostream>
using namespace std;

int max (int x,int y,int z)

int main(int argc, char* argv[])

{ int a,b,c;
cout <<"请输入a:";
cin >>a;
cout <<endl;
cout <<"请输入b:";
cin >>b;
cout <<endl;
cout <<"请输入c:";
cin >>c;
max=max (a,b,c);

return 0;
}

int max (int x,int y,int z)
{int t;
if x>y
t=x;
else
t=y;
if z>t
cout<<z<<endl;
else
cout<<t<<endl;
}

以下为修改后的程序,修改的地方看注释
#include <iostream>
using namespace std;

int max (int x,int y,int z); //注释加分号

int main(int argc, char* argv[])
{
int a,b,c;
cout <<"请输入a:";
cin >>a;
cout <<endl;
cout <<"请输入b:";
cin >>b;
cout <<endl;
cout <<"请输入c:";
cin >>c;
int maxv=max (a,b,c); //变量名与函数名相同

cout<<"max="<<maxv<<endl;

return 0;
}

int max (int x,int y,int z)
{
int t;
if (x>y)
t=x;
else
t=y;
if (z>t)
t=z; //这里没语法错误,但与求最大值意思不对

return t; //不要忘了返回值
}