求两个整数之间的最大值
#include<stdio.h>
int main()
{
int max(int x,int y);
int a,b,c;
scanf("%d,%d",&a,&b);
c = max(a,b);
printf("max = %d \n",c);
return 0;
}
int max(int x,int y)
{
int z;
if(x>y){
z = x;
}else{
z = y;
}
return z;
}
执行结果👇
image.png
求三个数之间的最大值
#include<stdio.h>
int main()
{
int max(int x,int y,int z);
int a,b,c,temp;
scanf("%d,%d,%d",&a,&b,&c);
temp = max(a,b,c);
printf("max = %d \n",temp);
return 0;
}
int max(int x,int y,int z)
{
int temp;
if(x>y){
temp = x;
}else{
temp = y;
}
if(temp > z){
return temp;
}else{
return z;
}
}
结果👇
image.png