5个数求最值

http://acm.nyist.net/JudgeOnline/problem.php?pid=31

c语言书上的题目

描述
设计一个从5个整数中取最小数和最大数的程序
输入
输入只有一组测试数据,为五个不大于1万的正整数
输出
输出两个数,第一个为这五个数中的最小值,第二个为这五个数中的最大值,两个数字以空格格开。
样例输入
1 2 3 4 5
样例输出
1 5
 1 #include<stdio.h>
 2 int main()
 3 {
 4     int a[5];
 5     int min=0;
 6     int max=0;
 7     for(int t=0;t<5;t++)
 8         scanf("%d",&a[t]);
 9     for(int t=1;t<5;t++)
10     {
11         if(a[max]<a[t])max=t;
12         if(a[min]>a[t])min=t;
13     }
14     printf("%d %d",a[min],a[max]);
15 }
原文地址:https://www.cnblogs.com/pojdd/p/7676437.html