# include<stdio.h> int main( ) { int max(int x,int y,int z); int a=3,b=4,c=5,d; ...
🚨 错误信息
# include<stdio.h>
int main( )
{
int max(int x,int y,int z);
int a=3,b=4,c=5,d;
scanf("%d %d %d",&a,&b,&c);
d=max(a,b,c);
printf("max=%d\n",d);
return 0;
}
int max(int x,int y,int z)
{
int m=x;
if(y>m)
m=y;
if(z>m)
m=z;
return(m);
}
🤖 AI解决方案
报错信息
error: expected ';' before 'max'
错误:在 'max' 前缺少分号
原因分析
在
main 函数中,函数声明 int max(int x,int y,int z); 后面缺少了分号。C/C++ 语言中,函数声明(也称为函数原型)的末尾必须加上分号,用于告知编译器该函数的存在、返回类型和参数列表。解决方案
在
main 函数中,将函数声明 int max(int x,int y,int z) 修改为 int max(int x, int y, int z);。c
#include int max(int x, int y, int z); // 添加了分号
int main() {
int a = 3, b = 4, c = 5, d;
scanf("%d %d %d", &a, &b, &c);
d = max(a, b, c);
printf("max=%d\n", d);
return 0;
}
int max(int x, int y, int z) {
int m = x;
if (y > m)
m = y;
if (z > m)
m = z;
return (m);
}