제출 #65836

#제출 시각아이디문제언어결과실행 시간메모리
65836josw530앵무새 (IOI11_parrots)C++98
컴파일 에러
0 ms0 KiB
#include "encoder.h"
#include "encoderlib.h"

int BIT_MASK[8] = {
	0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
};

void encode(int N, int M[])
{
  int i;
  
  
  for(i=0; i<N; i++)
  {
	  for(int j = 0; j<8; j++)
	  {
		  if(M[i]&BIT_MASK)
			send(i*8 + j);  
	  }
	
  }
    
}
#include "decoder.h"
#include "decoderlib.h"

int BIT_MASK[8] = {
	0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
};

void decode(int N, int L, int X[])
{
  int i, b;
  int msg[32] = {0};
  for(i=0; i<L; i++) {
    msg[X[i]/8] |= BIT_MASK[(X[i]%8];
  }

    for(i=0; i<N; i++) {
    output(msg[i]);
  }
 }

컴파일 시 표준 에러 (stderr) 메시지

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:17:12: error: invalid operands of types 'int' and 'int [8]' to binary 'operator&'
     if(M[i]&BIT_MASK)
        ~~~~^~~~~~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:13:36: error: expected ')' before ']' token
     msg[X[i]/8] |= BIT_MASK[(X[i]%8];
                                    ^
decoder.cpp:13:37: error: expected ']' before ';' token
     msg[X[i]/8] |= BIT_MASK[(X[i]%8];
                                     ^
decoder.cpp:10:10: warning: unused variable 'b' [-Wunused-variable]
   int i, b;
          ^