50分,求助
查看原帖
50分,求助
741732
small_Dongpo楼主2023/2/5 16:32

我的代码:

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

int a[1005];
int b[1005];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n - 1; ++i)
    {
        if (a[i] - a[i + 1] < 0)
        {
            b[i] = -(a[i] - a[i + 1]);
        }
        else
        {
            b[i] = a[i] - a[i + 1];
        }
    }
    sort(b + 1, b + n);
    bool f = 1;
    for (int i = 1; i <= n; ++i)
    {
        if (b[i] != i) f = 0;
    }
    if (f) cout << "Jolly";
    else cout << "Not jolly";
}
2023/2/5 16:32
加载中...