C语言怎么写!!编写一个程序,读入5个整数,然后确定并显示这组数种的最大整数和最小整数

来源:百度知道 编辑:UC知道 时间:2024/09/23 08:16:52
编写一个程序,读入5个整数,然后确定并显示这组数种的最大整数和最小整数,用c语言怎么写啊??
只允许用if语句的话怎么做到

#include "stdio.h"
main()
{ int a,b,c,d,e,max;
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
max=a;
if(b>max) max=b;
if(c>max) max=c;
if(d>max) max=d;
if(e>max) max=e;
printf("max=%d",max);
}

#include<stdio.h>
int array[5];
// 输入整数
void input()
{
int i;
printf("Please input 5 number:\n");
for(i=0;i<5;i++)
{
scanf("%d",&array[i]);//每输入完一个数据,请回车。
}
printf("Thank you ,input is end!\n");
}
// 显示函数
void display()
{
int j;
printf("the number you input is:\n");
for(j=0;j<5;j++)
printf("%d ",array[j]);
printf("\n");
}
// 取最大值
int getMAX()
{
int i,max;
max=array[0];
for(i=1;i<5;i++)
{
if(max<array[i])
max=array[i];
}