【題解】ZeroJudge c299: 1. 連號或不連號

題目敘述:https://zerojudge.tw/ShowProblem?problemid=c299

#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    while (cin >> n){
        int a[n];
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        sort(a, a+n);
        cout << a[0] << ' ' << a[n-1] << ' ';
        if (n-1 == a[n-1]-a[0]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
}
分享本文 Share with friends