c语言三个数求最大值 ,不用调用函数

如题所述

只有三个数,用if分支就可以了:

//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
    int a,b,c,max;
    printf("Input 3 integers...\n");
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b && a>=c)
        max=a;
    else if(b>=a && b>=c)
        max=b;
    else if(c>=a && c>=b)
        max=c;
    printf("The MAX is %d\n",max);
    return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-04-20
#include<stdio.h>
void main()
{int a,b,c,max;
scanf("%d%d%d",&a,&b,&c);
max=a;
if(b>max)max=b;
if(c>max)max=c;
printf("max=%d\n",max);
}本回答被网友采纳
第2个回答  2015-04-20
#define MAX1(a,b,c) ((a)>(b)?(a>c?a:c):(b>c?b:c))
第3个回答  2015-04-20
#include <stdio.h>
#include <stdlib.h>

void main()
{ int a,b,c;
int max;
printf("input three number :\n");
scanf("%d%d%d",&a,&b,&c); //

if(a>b)
max=c>a?c:a;
else
max=c>b?c:b;
printf("%d\n",max); /
system("pause");
return 0;
}

已经测试
相似回答