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

문제 <- 클릭

Purchasing Ambien In Mexico

https://forumlenteng.org/buy-zolpidem-online-eu 쉬운 문제인데 뭘 잘못한건지 채점이 안된다. 직접 테스트 하기에는 다 되는데 뭐가 문제인지.. 음.. https://arkipel.org/buy-ambien-online-india https://starbrighttraininginstitute.com/buy-generic-ambien-cr https://makeitagarden.com/buy-zolpidem-er-online 왠지 또 사소한 문제일것 같아 일단 올려두고 다음에 깨끗한 정신으로 살펴봐야겠다. (수정) 성공 했다…. if (0 <= x && x < 8 && 0 <= y && y < 8) 이부분 범위를 잘못 적었다. 이런 멍청한 실수를 하다니 난 아직 멀었네..

https://creightondev.com/2024/06/24/order-ambien-overnight

#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; }

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

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

https://www.ag23.net/buy-ambien-cr-online-canada