#15648: 試看看


hansen033 (HC)

學校 : 新北市私立南山高級中學
編號 : 71998
來源 : [1.161.18.58]
最後登入時間 :
2024-05-06 23:54:59
c299. 1. 連號或不連號 -- 106學年度全國資訊學科能力競賽 | From: [125.227.249.127] | 發表日期 : 2018-10-18 20:04

#include <iostream>
using namespace std;
//大到小
int main(){
int fun, r;
while( cin >> fun ){
r = 1;
int l[fun];
//輸入
for( int t = 0 ; t < fun ; t ++ ){
cin >> l[t];
}
//排序
for( int t = 0 ; t < fun - 1 ; t ++ ){
for( int t2 = 0 ; t2 < fun - 1 ; t2 ++ ){
if( l[t2] < l [t2 + 1] ){
int c = l[t2];
l[t2] = l[t2 + 1];
l[t2 + 1] = c;
}
}
}
//判斷
for( int t = 0 ; t < fun - 1 ; t ++ ){
if( l[t] - 1 != l[t + 1] ){
r = 0;
}
}
//輸出最大和最小
cout << l[fun - 1] << " " << l[0];
//對嗎?
if( r == 1 ){
cout << " yes";
} else {
cout << " no";
}
}
}

 
ZeroJudge Forum