#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n] = {};
for(int i = 0; i < n; i++){
cin >> a[i];
}
int d = 0;
sort(a, a + n);
bool b = true;
for(int i = 0; i < n - 1; i++){
if(a[i] != a[i + 1] - 1){
d = 0;
break;
}
else{
d = 1;
}
}
for(int i = 0; i < n; i++){
cout << a[i] << " ";
}
if (d == 1){
cout << "yes";
}
else{
cout << "no";
}
return 0;
}
#include
#includeusing namespace std;
int main()
{
int n;
cin >> n;
int a[n] = {};
for(int i = 0; i < n; i++){
cin >> a[i];
}
int d = 0;
sort(a, a + n);
bool b = true;
for(int i = 0; i < n - 1; i++){
if(a[i] != a[i + 1] - 1){
d = 0;
break;
}
else{
d = 1;
}
}
for(int i = 0; i < n; i++){
cout << a[i] << " ";
}
if (d == 1){
cout << "yes";
}
else{
cout << "no";
}
return 0;
}
只要輸出a[0]和a[n-1]就好了