打卡第二十天

求2个整数,3个整数的最大值,用同名函数实现
 一
1.运用if语句先比较其中两个数
2.再让其中大的和另一个数比较,最后大的即为最大值
二、
三、

#include<stdio.h>

int main()
{
int temp;
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a>b)
temp=a;
else temp=b;
printf("%d\n",temp);
if(c>temp)
printf("%d",c);
else printf("%d",temp);
return 0;

}

四、

#include<stdio.h>

int main()
{
int temp;
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a>b)
temp=a;
else temp=b;
printf("%d\n",temp);
if(c>temp)
printf("%d",c);
else printf("%d",temp);
return 0;

}

posted @ 2023-05-11 09:24  欧吼吼  阅读(19)  评论(0编辑  收藏  举报