Programming Challenges – 체크 확인 (Check the Check)

https://fotballsonen.com/2024/03/07/5n5m34hl https://elisabethbell.com/pjgbrzyg9 문제 <- 클릭

https://ncmm.org/spmjmv0e3w

https://giannifava.org/akaor8jj7m https://asperformance.com/uncategorized/aqwexvix7pi 쉬운 문제인데 뭘 잘못한건지 채점이 안된다. 직접 테스트 하기에는 다 되는데 뭐가 문제인지.. 음.. https://www.mominleggings.com/w0igt5c1to https://www.goedkoopvliegen.nl/uncategorized/htfztu4g7 https://musiciselementary.com/2024/03/07/l56dvt99 왠지 또 사소한 문제일것 같아 일단 올려두고 다음에 깨끗한 정신으로 살펴봐야겠다. https://worthcompare.com/6dn3vlo0k http://countocram.com/2024/03/07/7931hhps4f (수정) 성공 했다…. if (0 <= x && x < 8 && 0 <= y && y < 8) 이부분 범위를 잘못 적었다. 이런 멍청한 실수를 하다니 난 아직 멀었네..

#include #include using namespace std; class Chess { private: char field[8][8]; bool checkLange(int x, int y) { if (0 <= x && x < 8 && 0 <= y && y < 8) return true; return false; } int checkDirection(bool black, int x, int y, int xx, int yy) { if (!checkLange(x + xx, y + yy)) return 0; if (field[x + xx][y + yy] == '.') return checkDirection(black, x + xx, y + yy, xx, yy); else if (field[x + xx][y + yy] == (black ? 'K' : 'k')) { return 1; } else { return 2; } } int checkLocation(bool black, int x, int y, int xx, int yy) { if (!checkLange(x + xx, y + yy)) return 0; if (field[x + xx][y + yy] == (black ? 'K' : 'k')) { return 1; } else { return 2; } } bool pawn(bool black, int x, int y) { if (black) { if (checkLocation(black, x, y, 1, -1) == 1) return true; if (checkLocation(black, x, y, 1, 1) == 1) return true; } else { if (checkLocation(black, x, y, -1, -1) == 1) return true; if (checkLocation(black, x, y, -1, 1) == 1) return true; } return false; } bool king(bool black, int x, int y) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (!(i == 0 && j == 0)) if (checkLocation(black, x, y, i, j) == 1) return true; } } return false; } bool knight(bool black, int x, int y) { if (checkLocation(black, x, y, -2, -1) == 1) return true; if (checkLocation(black, x, y, -1, -2) == 1) return true; if (checkLocation(black, x, y, 1, -2) == 1) return true; if (checkLocation(black, x, y, 2, -1) == 1) return true; if (checkLocation(black, x, y, 2, 1) == 1) return true; if (checkLocation(black, x, y, 1, 2) == 1) return true; if (checkLocation(black, x, y, -1, 2) == 1) return true; if (checkLocation(black, x, y, -2, 1) == 1) return true; return false; } bool rook(bool black, int x, int y) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (!(i == 0 && j == 0)) if (i == 0 || j == 0) if (checkDirection(black, x, y, i, j) == 1) return true; } } return false; } bool bishop(bool black, int x, int y) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i != 0 && j != 0) if (checkDirection(black, x, y, i, j) == 1) return true; } } return false; } bool queen(bool black, int x, int y) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (!(i == 0 && j == 0)) if (checkDirection(black, x, y, i, j) == 1) return true; } } return false; } public: bool input() { std::string buffer; int dotCounter = 0; for (int i = 0; i < 8; ++i) { std::getline(std::cin,buffer); for (int j = 0; j < 8; ++j) { if (buffer[j] == '.') dotCounter++; field[i][j] = buffer[j]; } } if (dotCounter == 64) { return true; } else { return false; } } int checkTheCheck() { for (int i = 0; i < 8; ++i) { for (int j = 0; j < 8; ++j) switch (field[i][j]) { case 'r': if (rook(true, i, j)) return 1; break; case 'R': if (rook(false, i, j)) return 2; break; case 'b': if (bishop(true, i, j)) return 1; break; case 'B': if (bishop(false, i, j)) return 2; break; case 'q': if (queen(true, i, j)) return 1; break; case 'Q': if (queen(false, i, j)) return 2; break; case 'p': if (pawn(true, i, j)) return 1; break; case 'P': if (pawn(false, i, j)) return 2; break; case 'n': if (knight(true, i, j)) return 1; break; case 'N': if (knight(false, i, j)) return 2; break; case 'k': if (king(true, i, j)) return 1; break; case 'K': if (king(false, i, j)) return 2; break; } } return 0; } }; int main() { Chess chess; std::string buffer; int gameNumber = 0; while (!chess.input()) { gameNumber++; int check = chess.checkTheCheck(); if (check == 1) cout << "Game #" << gameNumber << ": white king is in check." << endl; else if (check == 2) cout << "Game #" << gameNumber << ": black king is in check." << endl; else cout << "Game #" << gameNumber << ": no king is in check." << endl; std::getline(std::cin,buffer); } return 0; }

Tramadol Cheap Online

One thought on “ Programming Challenges – 체크 확인 (Check the Check)

  1. Yoon

    https://ncmm.org/wns1zhal55l 정말열심히하시네요^^ 멋져요!♡

    Buy Cheap Tramadol Online

Yoon에 답글 남기기 응답 취소

https://worthcompare.com/x6afj9zyf 이메일 주소는 공개되지 않습니다.

https://www.goedkoopvliegen.nl/uncategorized/tuvyaqtq

https://www.jamesramsden.com/2024/03/07/t4u9w9c

https://elisabethbell.com/zv0p303u

https://tankinz.com/6u3ufyw6j You may use these HTML tags and attributes:

https://asperformance.com/uncategorized/ooxvfbuo1k <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

http://countocram.com/2024/03/07/h71eo1or

http://countocram.com/2024/03/07/915m2l898ls

Cheap Tramadol Online

https://musiciselementary.com/2024/03/07/ir1owlbfg44

https://www.lcclub.co.uk/yw3j021

https://www.jamesramsden.com/2024/03/07/m9ujorl98z

https://wasmorg.com/2024/03/07/62dbyv6n

https://www.worldhumorawards.org/uncategorized/tgbh9pchqld

https://fotballsonen.com/2024/03/07/wv3r2tbu0tr 이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

Purchase Tramadol Online Uk