Submission #145818

# Submission time Handle Problem Language Result Execution time Memory
145818 2019-08-21T07:04:51 Z leewj1025 짝수 정렬 (tutorial3) C++14
Compilation error
0 ms 0 KB
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
void Report (int val){
	assert(++result_n <= N);
	printf("%d ", val);
}
void sort_even(int N, int *A) {
	int i;
	for (i = 0; i < N; i++) {
		if (A[i] % 2 == 0) Report(A[i]);
	}
}
static int N, *A;

int result_n;



int main(){
	int i, tmp;

	tmp = scanf("%d", &N);
	assert(tmp == 1);

	A = (int*) malloc( sizeof(int) * N );
	for(i = 0; i < N; i++){
		tmp = scanf("%d", &A[i]);
		assert(tmp == 1);
	}

	sort_even(N, A);

	return 0;
}

Compilation message

In file included from tutorial3.cpp:2:0:
tutorial3.cpp: In function 'void Report(int)':
tutorial3.cpp:5:11: error: 'result_n' was not declared in this scope
  assert(++result_n <= N);
           ^
tutorial3.cpp:5:23: error: 'N' was not declared in this scope
  assert(++result_n <= N);
                       ^