用c语言
# include <stdio.h>
int main()
{
int a,b,c,d;
d=max(3,99,88);
printf("max = %d\n",d);
}
int max(int x,int y,int z)
{
int m ,n;
if(x>y)
{m = x;}
else
{m = y;}
if(m>z)
{n = m;}
else
{n = z;}
return(n);
}
如果比较的是整数,代码如下:
#include "stdafx.h"
int main()
{
int a,b,c;
printf("请输入三个整数,用空格分开:");
scanf("%d %d %d",&a,&b,&c);
int t;
if(a<b){t=a;a=b;b=t;}
if(a<c){t=a;a=c;c=t;}
if(b<c){t=b;b=c;c=t;}
printf("%d >%d >%d",a,b,c);
return 0;
}