如題,我在這裡過了,為什麼Online Judge上過不了?
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
int comp(const void*p , const void*q);
int main()
{
int b;
int n;
while(cin >> n)
{
int d[4000] = {0};
int a[4000] = {0};
int A[4000] = {0};
for(int i = 0 ; i < n ; i++)
{
cin >> d[i];
/* cout << d[i] << " ";*/
}
/* cout << endl;*/
for(int i = 0 ; i < n - 1 ; i++)
{
a[i] = d[i+1] - d[i];
/*cout << a[i] << endl;*/
if(a[i]>=0)
{
A[i] = a[i];
}
else
{
A[i] = (-1) * a[i];
}
/*cout <<A[i] << " ";*/
}
qsort(A,n-1,sizeof(int),comp);
b = 0;
for(int i = 0 ; i < n-1 ; i++)
{
/* cout << A[i]<< " ";*/
if(A[0]==1)
{
if(A[i+1] - A[i] == 1)
{
b++;
}
}
else
{
break;
}
}
/* cout << b << endl;*/
if(b == n-2)
{
cout << "Jolly" << endl;
}
else
{
cout << "Not jolly" << endl;
}
}
return 0;
}
int comp(const void*p , const void*q)
{
return *(int*)p - *(int*)q;
}