刚学习c语言,入门,老师布置了个任务让我们打出来就行,但编译提示有错,请问怎么改?这个题什么意思?

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)
{
if(a>b)return a;else return b;
}

编译器:Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/sin.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

sin.exe - 1 error(s), 0 warning(s)
Compiling...
sin.cpp
F:\sin\sin.cpp(6) : error C2065: 'printf' : undeclared identifier
F:\sin\sin.cpp(7) : error C2065: 'scanf' : undeclared identifier
F:\sin\sin.cpp(10) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.

第1个回答  2018-07-24

    把main中的int max(int a,int b);删除。

    请在int max(int a,int b);前面加一句#include <stdio.h>。

    把main()改成int main()。

    在printf("maxmum=%d",z);后加一句return 0;。

第2个回答  2018-07-24
printf 与 scanf 应用的话应该是都要加库 <stdio.h> 的吧!版主你加了吗?追问

谢谢

本回答被提问者采纳
第3个回答  2018-07-24
少个头文件 #include<stdio.h> 这段加到你代码最上面就行
相似回答