~cpp 
#include <iostream>
using namespace std;
const int size = 65535;
void check_possible (int max);                // Jolly판단 자체가 가능한 수열인가 검사
void check_Jolly (int max, int ar[]);         // Jolly여부를 판단
void show_num (int max, int ar[]);            // 입력한 숫자 출력
int main()
{
	int array[size];
	int num;
	int total_num = 0;
	int i = 0;
	cout << "숫자를 입력하세요 (종료 : q) : ";
	while (cin >> num)
	{
		if (i == 0 && num > 3000)             // 첫번째 수가 3000이 넘는지 검사
		{
			system("cls");
		    cout << "첫번째 숫자는 3000을 넘어서는 안됩니다." 
				 << "숫자를 입력하세요 (종료 : q) : ";
			continue;
		}
		if (num <= 0)                         // 0이하의 정수가 입력되었는지 검사
		{	
			system("cls");
		    cout << "1이상의 정수를 입력하셔야 합니다." 
				 << "숫자를 입력하세요 (종료 : q) : ";
			continue;
		}
		array[i] = num;
		i++;
		system("cls");
		show_num (i + 1, array);
		cout << "숫자를 입력하세요 (종료 : q) : ";
	}
	system("cls");
	total_num = i + 1;
	check_possible (total_num);
	show_num (total_num, array);
	check_Jolly( total_num, array);
	return 0;
}
void check_possible (int max)
{
	if (max <= 1)
	{	
		cout << "입력된 숫자가 없습니다. 프로그램을 종료합니다." << endl;
		exit(0);
	}
}
void check_Jolly (int max, int ar[])
{	
	int temp;
	
	for (int i = 1; i < max - 1; i++)
	{	
		for (int j = 0; j < max - 1; j++)
		{
			temp = ar[j] - ar[j + 1] ;
			if (temp < 0)
				temp = -temp;
			if (temp == i)
				break;
		}
		if (temp != i)
		{
			cout << "*** Not Jolly ***" << endl;
			exit(0);
		}
	}
	cout << "*** Jolly ***" << endl;
}
void show_num (int max, int ar[])
{
	cout << "<Numbers Inputed>" << endl;
	for (int i = 0; i < max - 1; i++)
		cout << ar[i] << " ";
	cout << endl;
}