求助
查看原帖
求助
778802
Xssion37_XY楼主2023/5/21 22:00
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
	int a_len;
	bool key = true;
	cin >> a_len;
	int a[a_len] = {}, b[a_len - 1] = {};
	for (int i = 0; i <= a_len - 1; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= a_len - 2; i++) {
		b[i] = abs(a[i] - a[i + 1]);
	}
	sort(b, b + a_len - 1);
	for (int i = 0; i <= a_len - 1; i++) {
		if (a[i] != i + 1) {
			key = false;
			break;
		}
	}
	if (key) {
		cout << "Jolly";
	}
	else{
		cout << "Not jolly";
	}
}

它只输出不符合的答案

不知道哪里错了惹/kk

2023/5/21 22:00
加载中...