nyoj_31

题目描述:五个数求最值。

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int a[5];
    for(int i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+5);
    printf("%d %d",a[0],a[4]);
    return 0;
}
时间: 2024-08-02 14:46:34

nyoj_31的相关文章

NYOJ_31 5个数求最值

题目地址 难度1. 两种实现方法: 1.自己写排序算法,本文用的是简单选择排序. 2.调用库函数.需要加入头文件,调用sort函数.或者min_element max_element 函数. #include<iostream> //#include<algorithm> using namespace std; void Swap(int &a,int &b) { int temp; temp = a; a = b; b = temp; } /*简单选择排序 n为