Zheaoli / do-something-right

MIT License
37 stars 3 forks source link

2022-12-08 #445

Open Zheaoli opened 1 year ago

Zheaoli commented 1 year ago

2022-12-08

dreamhunter2333 commented 1 year ago
#include <iostream>
#include <string>
using namespace std;
/*
 * @lc app=leetcode.cn id=1812 lang=cpp
 *
 * [1812] 判断国际象棋棋盘中一个格子的颜色
 */

// @lc code=start
class Solution
{
public:
    bool squareIsWhite(string coordinates)
    {
        return ((coordinates[0] - 'a' + 1 +
                 (int)coordinates[1] - '0') %
                2) == 1;
    }
};
// @lc code=end
int main(int argc, char const *argv[])
{
    Solution s;
    cout << s.squareIsWhite("a1") << endl;
    cout << s.squareIsWhite("h3") << endl;
    cout << s.squareIsWhite("c7") << endl;
    return 0;
}

微信id: 而我撑伞 来自 vscode 插件