现在的位置: 首页 > 综合 > 正文

求两、三个数中较大者的函数

2012年11月09日 ⁄ 综合 ⁄ 共 503字 ⁄ 字号 评论关闭
int max(int a,int b)
{
 int t;
 if (a>b) t=a;
 else t=b;
 return t;
}

int max(int a,int b,int c)
{
 int t;
 if (a>b)
 if (a>c)
   t=a;
 else
   t=c;
 else
 if (b>c)
   t=b;
 else
   t=c;
 return t;
}

#include <stdio.h>
#include 
<conio.h>
int max(int,int,int);
void main()
{
 
int a,b,c,t;
 clrscr();
 printf(
"Please input tree number:");
 scanf(
"%d,%d,%d",&a,&b,&c);
 t
=max(a,b,c);
 printf(
"The max number is :%d",t);
}


int max(int a,int b,int c)
{
 
int t;
 
if (a>b)
    
if (a>c)
      t
=a;
    
else
      t
=c;
 
else
    
if (b>c)
      t
=b;
    
else
      t
=c;
 
return t;
}


抱歉!评论已关闭.