답안 #147352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147352 2019-08-29T08:04:48 Z IohcEjnim 비교 (balkan11_cmp) C++14
컴파일 오류
0 ms 0 KB
#include "cmp.h"

// 6 8 10 12
// 6 48 480 ??

int sz[5] = {0, 12, 10, 8, 6};
int num[5][20] = 
{
	{0, },
	{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, },
	{13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, }, 
	{23, 24, 25, 26 ,27, 28, 29, 30, 0, }, 
	{31, 32, 33, 34, 35, 36, 0, }
};
int div[5] = {0, 480, 48, 6, 1};

void remember(int n) 
{
	for (int i = 1; i <= 4; i++)
	{
		int val = n / div[i];
		n %= div[i];
		bit_set(num[i][val]);
	}
}

int compare(int b) 
{
	for (int i = 1; i <= 4; i++)
	{
		int val = n / div[i];
		n %= div[i];
		int res = bit_get(num[i][val]);
		if (res == 1) continue;

		int mode = false;
		if (val >= sz[i]/2) mode = true;
		int s = mode ? sz[i]/2 : 0;
		int e = mode ? sz[i] : sz[i]/2;

		for (int j = s; j < e; j++)
		{
			if (j == val) continue;
			res = bit_get(num[i][j]);
			if (res == 0) continue;

			return j < val ? 1 : -1;
		}

		return mode ? 1 : -1;
	}
	return 0;
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:31:13: error: 'n' was not declared in this scope
   int val = n / div[i];
             ^