U E D R , A S I H C RSS

Jolly Jumpers/오승균

Jolly Jumpers

~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;
}

Thread

히(?) . 히 -_-;;; .
. --
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:34
Processing time 0.0095 sec