找两个数中最大者
描述
本题要求对两个整数a和b,输出其中较大的数。
函数接口定义:
int max(int a, int b);
其中a和b是用户传入的参数,函数返回的是两者中较大的数。
#include<stdio.h>
#include<math.h>
int max(int x,int y)//定义函数。
{
int M;
if(x>y)
M=x;
else
M=y;
return M;//定义的结果就是输出M即最大值。
}
int main()
{
int a,b,s;
scanf("%d%d",&a,&b);
s=max(a,b);//将a,b分别赋值于x,y,并且M的值给予s。
printf("%d",s);
}