作业帮 > 综合 > 作业

C语言帮忙找出下列各段程序中的语法和逻辑错误.

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/10 08:12:23
C语言帮忙找出下列各段程序中的语法和逻辑错误.
main()
{
int num1,num2;
printf("Please enter two numbers:");
scanf("%d%d",&num1,&num2);
printf("Max=%d,Min=%d\n",max_min(int num1,int numb2));
}
int max_min(number1,number2)
{
int max,min;
max=number1>number2?number1:number2;
min=number1>number2?number2:number2;
return(max);
return(min);
}
C语言帮忙找出下列各段程序中的语法和逻辑错误.
main()
{
int num1,num2;
printf("Please enter two numbers:");
scanf("%d%d",&num1,&num2);
printf("Max=%d,Min=%d\n",max_min(int num1,int numb2)); //里面是函数调用吗?看着有点象是声明啊,调用实参不用加类型名吧
}
int max_min(number1,number2) //形参没定义类型
{
int max,min;
max=number1>number2?number1:number2;
min=number1>number2?number2:number2;
return(max);
return(min); //返回值只能有1个,第二个执行不到的
}
改:将输出改在函数中,避免只能返回一个值的问题
main()
{
void max_min(int num1,int numb2);//声明函数
int num1,num2;
printf("Please enter two numbers:");
scanf("%d%d",&num1,&num2);
max_min(num1,numb2);
}
void max_min(int number1,int number2)
{
int max,min;
max=number1>number2?number1:number2;
min=number1>number2?number2:number2;
printf("Max=%d,Min=%d\n",max,min);
}