就这个简单的程序而言 为什么有错误无法执行 错在那里?

来源:百度知道 编辑:UC知道 时间:2024/06/23 00:29:28
int max(int a,int b);
main()
{
int x,y,z;
int max(int a,int b);
printf("input two numbers:\n");
scanf("%d%d",&x,&y);
z=max(x,y);
printf("maxmum=%d",z);
}
int max(int a,int b)
}

运行后出现以下错误提示
--------------------Configuration: 456 - Win32 Debug--------------------
Compiling...
456.cpp
E:\C++\456.cpp(6) : error C2065: 'printf' : undeclared identifier
E:\C++\456.cpp(7) : error C2065: 'scanf' : undeclared identifier
E:\C++\456.cpp(10) : warning C4508: 'main' : function should return a value; 'void' return type assumed
E:\C++\456.cpp(12) : error C2143: syntax error : missing ';' before '}'
E:\C++\456.cpp(12) : error C2143: syntax error : missing ';' before '}'
E:\C++\456.cpp(12) : error C2143: syntax error : missing ';' before

缺少头文件,函数没定义
#include <stdio.h>
int max(int a,int b);
main()
{
int x,y,z;
int max(int a,int b);
printf("input two numbers:\n");
scanf("%d%d",&x,&y);
z=max(x,y);
printf("maxmum=%d",z);
}
int max(int a,int b)
{
return a>b?a:b;
}

你还是认真看看程序的格式再写吧,打好基础,磨刀不误砍柴工.

C++很难的,错误很明显