不知道為什麼,最後會多輸出一行(OLE),上網查也找不到,可以幫我看一下嗎?
# include <bits/stdc++.h>
using namespace std;
int main()
{
int n,x,v;
while (cin >> n){
vector<int> C(n,0);
cin >> x;
bool ans=true;
for (int i=0; i<n-1; i++){
cin >> v;
int Check=abs(x-v);
if (Check == 0 || Check > n-1 || C[Check] != 0) {ans=false; break;}
else C[Check]++;
x = v;
}
if (ans) cout << "Jolly" << '\n';
else cout << "Not jolly" << '\n';
}
return 0;
}
if (Check == 0 || Check > n-1 || C[Check] != 0) {ans=false; break;}
不能break,後面的數字會沒有輸入到