답안 #4736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4736 2013-12-23T11:18:04 Z ainta 중앙값 배열 (balkan11_medians) C++
컴파일 오류
0 ms 0 KB
#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
set<int>Set;
set<int>::iterator it, it2;
int main()
{
	int a, b, i;
	scanf("%d", &n);
	for (i = 1; i <= 2 * n - 1; i++)
		Set.insert(i);
	for (i = 1; i <= n; i++){
		scanf("%d", &a);
		if (i == 1){
			printf("%d ", a);
			Set.erase(Set.find(a));
			b = a;
			continue;
		}
		if (Set.find(a) != Set.end()){
			Set.erase(Set.find(a));
			printf("%d ", a);
			if (a < b)it = Set.begin();
			else it = Set.end(), it--;
			printf("%d ", *it);
			Set.erase(it);
			b = a;
			continue;
		}
		if (a <= b)it = Set.begin();
		else it = Set.end(), it--;
		printf("%d ", *it);
		Set.erase(it);
		if (a < b)it = Set.begin();
		else it = Set.end(), it--;
		printf("%d ", *it);
		Set.erase(it);
		b = a;
	}
	return 0;
}

Compilation message

medians.cpp:1:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 ^
medians.cpp: In function 'int main()':
medians.cpp:11:15: error: 'n' was not declared in this scope
  scanf("%d", &n);
               ^
medians.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a);
                  ^