{"id":9141,"date":"2024-05-11T15:01:01","date_gmt":"2024-05-11T07:01:01","guid":{"rendered":""},"modified":"2024-05-11T15:01:01","modified_gmt":"2024-05-11T07:01:01","slug":"\uff23\u8bed\u8a00\uff0b\u4e8c\u7ef4\u6570\u7ec4\uff0b\u975e\u9012\u5f52\u5b9e\u73b0\u4e94\u5b50\u68cb\u6e38\u620f\uff08\u5de5\u7a0b\u5b8c\u6210\u5ea6\uff1a100%\uff09","status":"publish","type":"post","link":"https:\/\/mushiming.com\/9141.html","title":{"rendered":"\uff23\u8bed\u8a00\uff0b\u4e8c\u7ef4\u6570\u7ec4\uff0b\u975e\u9012\u5f52\u5b9e\u73b0\u4e94\u5b50\u68cb\u6e38\u620f\uff08\u5de5\u7a0b\u5b8c\u6210\u5ea6\uff1a100%\uff09"},"content":{"rendered":"
\u81ea\u5df1\u5199\u7684\u4e00\u4e2aC\u8bed\u8a00\u7248\u4e94\u5b50\u68cb\uff0c\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n
1\uff64\u767d\u5b50\u4e3aO;<\/p>\n
2\uff64\u9ed1\u5b50\u4e3a@\uff1b<\/p>\n
3\uff64\u767d\u5b50\u5148\u624b\uff1b<\/p>\n
4\uff64\u683c\u5b50\u5360\u6ee1\u65f6\u4e3a\u5e73\u5c40\uff1b<\/p>\n
5\uff64\u56db\u4e2a\u65b9\u5411\u4e0a\u6709\u8fde\u7eed\u4e94\u4e2a\u5b50\u4e3a\u80dc\u5229\uff1b<\/p>\n
6\uff64\u5982\u679c\u9009\u62e90 3\u8868\u793a\u9009\u7684\u7b2c1\u884c\u4e0e\u7b2c4\u5217\uff1b<\/p>\n
\u5907\u6ce8\uff1a<\/p>\n
1\u3001\u672c\u7a0b\u5e8f\u4f1a\u6301\u7eed\u8fdb\u884c\u4ee3\u7801\u4e0e\u6d41\u7a0b\u7684\u5b8c\u5584\uff1b<\/p>\n
2\u3001\u6211\u8fd8\u5199\u4e86\u4e00\u4e2aJava\u7248\u7684\u4e94\u5b50\u68cb\uff1aJava\u8bed\u8a00\uff0b\u4e8c\u7ef4\u6570\u7ec4\uff0b\u975e\u9012\u5f52\u5b9e\u73b0\u4e94\u5b50\u68cb\u6e38\u620f<\/p>\n
\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u76f4\u63a5\u4e0a\u4ee3\u7801\uff1a<\/p>\n
\/*\n\u89c4\u5219\uff1a\n1\uff64\u767d\u5b50\u4e3aO;\n2\uff64\u9ed1\u5b50\u4e3a@\uff1b\n3\uff64\u767d\u5b50\u5148\u624b\uff1b\n4\uff64\u683c\u5b50\u5360\u6ee1\u65f6\u4e3a\u5e73\u5c40\uff1b\n5\uff64\u56db\u4e2a\u65b9\u5411\u4e0a\u6709\u8fde\u7eed\u4e94\u4e2a\u5b50\u4e3a\u80dc\u5229\uff1b\n6\uff64\u5982\u679c\u9009\u62e90 3\u8868\u793a\u9009\u7684\u7b2c1\u884c\u4e0e\u7b2c4\u5217\uff1b\n*\/\n#include <stdio.h>\n\n#define N 16\n\n\/\/\u663e\u793a\u4e94\u5b50\u68cb\u68cb\u76d8\nvoid wzq_show(char (*GAME)[N]) {\n printf(\"\u4e94\u5b50\u68cb\u68cb\u76d8\u5982\u4e0b\uff1a\\n\");\n for (int i = 0; i < N; i++) {\n for (int j = 0; j < N; j++) {\n printf(\"%c \", GAME[i][j]);\n }\n printf(\"\\n\");\n }\n printf(\"\\n\");\n}\n\n\/\/\u521d\u59cb\u5316\u4e94\u5b50\u68cb\u68cb\u76d8\nvoid wzq_init(char (*GAME)[N]) {\n for (int i = 0; i < N; i++) {\n for (int j = 0; j < N; j++) {\n GAME[i][j] = '+';\n }\n }\n \/\/ memset(GAME,'+',N*N);\n}\n\n\/\/\u6e38\u620f\u662f\u5426\u80dc\u5229\u7684\u8fd0\u7b97,\u4e00\u65e6\u6709\u4eba\u80dc\u5229\u5219\u8fd4\u56de1\nint wzq_play(int a, int b, char (*GAME)[N]) {\n \/\/\u8fd9\u4e2a\u5c40\u90e8count\u662f\u8ba1\u7b97\u5f53\u524d\u68cb\u76d8\u4e0b\u4e86\u591a\u5c11\u4e2a\u68cb\u5b50\n \/\/\u5907\u6ce81\uff1a\u4f60\u4e5f\u53ef\u4ee5\u4ece\u5916\u90e8\u628a\u5916\u9762\u7684\u90a3\u4e2acount\u4f20\u8fdb\u6765\u5e76\u7528count+1\u4ee3\u66ff\u8fd9\u4e2a\u5c40\u90e8count\u53ca\u4e0b\u9762\u7684for\u5faa\u73af\n \/\/\u5907\u6ce82\uff1a\u4f60\u4e5f\u53ef\u4ee5\u5728\u5916\u90e8\u641e\u4e00\u4e2aboolean\u4f20\u8fdb\u6765\u6807\u8bc6\u5f53\u524d\u662f\u54ea\u4e00\u65b9\u521a\u4e0b\u7684\u5b50\u6765\u4ee3\u66ff\u8fd9\u4e2a\u5c40\u90e8\u7684count\u53ca\u4e0b\u9762\u7684for\u5faa\u73af\n int count = 0;\n for (int i = 0; i < N; i++) {\n for (int j = 0; j < N; j++) {\n if ('O' == GAME[i][j] || '@' == GAME[i][j]) {\n count++;\n }\n }\n }\n \/\/\u65b9\u5411-\u4e0a\u7684\n for (int j = b - 4; j < b + 4; j++) {\n if (j < 0 || j > N - 1) {\n continue;\n }\n if (0 != count % 2) {\n for (int i = 0; i < 5; i++) {\n if (j + i < 0 || j + i > N - 1) {\n break;\n }\n if ('@' == GAME[a][j + i] || '+' == GAME[a][j + i]) {\n break;\n }\n if ('O' == GAME[a][j + i] && 4 == i) {\n printf(\"\u606d\u559c\u4f60\uff0c\u767d\u5bb6\uff0d\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n } else {\n for (int i = 0; i < 5; i++) {\n if (j + i < 0 || j + i > N - 1) {\n break;\n }\n if ('O' == GAME[a][j + i] || '+' == GAME[a][j + i]) {\n break;\n }\n if ('@' == GAME[a][j + i] && 4 == i) {\n printf(\"\u606d\u559c\u4f60\uff0c\u9ed1\u5bb6\uff0d\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n }\n }\n\n \/\/\u65b9\u5411|\u4e0a\u7684\n for (int i = a - 4; i < a + 4; i++) {\n if (i < 0 || i > N - 1) {\n continue;\n }\n if (0 != count % 2) {\n for (int j = 0; j < 5; j++) {\n if (i + j < 0 || i + j > N - 1) {\n break;\n }\n if ('@' == GAME[i + j][b] || '+' == GAME[i + j][b]) {\n break;\n }\n if ('O' == GAME[i + j][b] && 4 == j) {\n printf(\"\u606d\u559c\u4f60\uff0c\u767d\u5bb6\uff5c\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n } else {\n for (int j = 0; j < 5; j++) {\n if (i + j < 0 || i + j > N - 1) {\n break;\n }\n if ('O' == GAME[i + j][b] || '+' == GAME[i + j][b]) {\n break;\n }\n if ('@' == GAME[i + j][b] && 4 == j) {\n printf(\"\u606d\u559c\u4f60\uff0c\u9ed1\u5bb6\uff5c\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n }\n }\n\n \/\/\u65b9\u5411\\\u4e0a\u7684\n for (int i = a - 4, j = b - 4; i < a + 4 && j < b + 4; i++, j++) {\n if (i < 0 || i > N - 1 || j < 0 || j > N - 1) {\n continue;\n }\n if (0 != count % 2) {\n for (int k = 0; k < 5; k++) {\n if (i + k < 0 || i + k > N - 1 || j + k < 0 || j + k > N - 1) {\n break;\n }\n if ('@' == GAME[i + k][j + k] || '+' == GAME[i + k][j + k]) {\n break;\n }\n if ('O' == GAME[i + k][j + k] && 4 == k) {\n printf(\"\u606d\u559c\u4f60\uff0c\u767d\u5bb6\uff3c\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n } else {\n for (int k = 0; k < 5; k++) {\n if (i + k < 0 || i + k > N - 1 || j + k < 0 || j + k > N - 1) {\n break;\n }\n if ('O' == GAME[i + k][j + k] || '+' == GAME[i + k][j + k]) {\n break;\n }\n if ('@' == GAME[i + k][j + k] && 4 == k) {\n printf(\"\u606d\u559c\u4f60\uff0c\u9ed1\u5bb6\uff3c\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n }\n }\n\n \/\/\u65b9\u5411\/\u4e0a\u7684\n for (int i = a + 4, j = b - 4; i > a - 4 && j < b + 4; i--, j++) {\n if (i < 0 || i > N - 1 || j < 0 || j > N - 1) {\n continue;\n }\n if (0 != count % 2) {\n for (int k = 0; k < 5; k++) {\n if (i - k < 0 || i - k > N - 1 || j + k < 0 || j + k > N - 1) {\n break;\n }\n if ('@' == GAME[i - k][j + k] || '+' == GAME[i - k][j + k]) {\n break;\n }\n if ('O' == GAME[i - k][j + k] && 4 == k) {\n printf(\"\u606d\u559c\u4f60\uff0c\u767d\u5bb6\/\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n } else {\n for (int k = 0; k < 5; k++) {\n if (i - k < 0 || i - k > N - 1 || j + k < 0 || j + k > N - 1) {\n break;\n }\n if ('O' == GAME[i - k][j + k] || '+' == GAME[i - k][j + k]) {\n break;\n }\n if ('@' == GAME[i - k][j + k] && 4 == k) {\n printf(\"\u606d\u559c\u4f60\uff0c\u9ed1\u5bb6\/\u65b9\u5411\u4e0a\u83b7\u80dc!\\n\");\n return 1;\n }\n }\n }\n }\n return 0;\n}\n\nint main() {\n char GAME[N][N] = {0};\n int count = 0; \/\/\u8f6e\u6362\u843d\u5b50\u8ba1\u7b97\n int m = 0, n = 0; \/\/\u767d\u5bb6\n int x = 0, y = 0; \/\/\u9ed1\u5bb6\n int res = 0;\n wzq_init(GAME);\n wzq_show(GAME);\n while (1) {\n \/\/\u5f53\u68cb\u76d8\u683c\u5b50\u88ab\u4e0b\u6ee1\u4e86\u65f6\n if (N * N == count) {\n printf(\"\u68cb\u76d8\u5df2\u7ecf\u4e0b\u6ee1\u4e86\uff0c\u5e73\u5c40!\\n\");\n return 0;\n }\n if (0 == count % 2) {\n printf(\"\u8bf7\u767d\u5bb6\u843d\u5b50\uff08\u4f8b\u59820 3\u62161 3\uff09\uff1a\");\n scanf(\"%d%d\", &m, &n);\n while (m < 0 || m > N - 1 || n < 0 || n > N - 1) {\n printf(\"\u8f93\u5165\u7684\u5750\u6807\u8d85\u51fa\u8303\u56f4\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\uff1a\");\n scanf(\"%d%d\", &m, &n);\n }\n while ('+' != GAME[m][n]) {\n printf(\"\u6b64\u5904\u5df2\u7ecf\u843d\u8fc7\u5b50\uff0c\u8bf7\u91cd\u65b0\u843d\u5b50\uff1a\");\n scanf(\"%d%d\", &m, &n);\n }\n GAME[m][n] = 'O';\n res = wzq_play(m, n, GAME);\n if (1 == res) {\n wzq_show(GAME);\n printf(\"\u7a0b\u5e8f\u7ed3\u675f\\n\");\n return 0;\n }\n } else {\n printf(\"\u8bf7\u9ed1\u5bb6\u843d\u5b50\uff08\u4f8b\u59820 3\u62161 3\uff09\uff1a\");\n scanf(\"%d%d\", &x, &y);\n while (x < 0 || x > N - 1 || y < 0 || y > N - 1) {\n printf(\"\u8f93\u5165\u7684\u5750\u6807\u8d85\u51fa\u8303\u56f4\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\uff1a\");\n scanf(\"%d%d\", &x, &y);\n }\n while ('+' != GAME[x][y]) {\n printf(\"\u6b64\u5904\u5df2\u7ecf\u843d\u8fc7\u5b50\uff0c\u8bf7\u91cd\u65b0\u843d\u5b50\uff1a\");\n scanf(\"%d%d\", &x, &y);\n }\n GAME[x][y] = '@';\n res = wzq_play(x, y, GAME);\n if (1 == res) {\n wzq_show(GAME);\n printf(\"\u7a0b\u5e8f\u7ed3\u675f\\n\");\n return 0;\n }\n }\n count++;\n wzq_show(GAME);\n }\n}\n<\/code><\/pre>\n\u82f9\u679c\u7b14\u8bb0\u672c\u4e0bC\u73af\u5883\u8fd0\u884c\u6548\u679c\uff1a <\/p>\n
<\/p>\n
\u5728\u7ebfC\u7f16\u8bd1\u5668Lightly\u7684\u8fd0\u884c\u6548\u679c\uff1a<\/p>\n
\n \n<\/div><\/p>\n","protected":false},"excerpt":{"rendered":"\uff23\u8bed\u8a00\uff0b\u4e8c\u7ef4\u6570\u7ec4\uff0b\u975e\u9012\u5f52\u5b9e\u73b0\u4e94\u5b50\u68cb\u6e38\u620f\uff08\u5de5\u7a0b\u5b8c\u6210\u5ea6\uff1a100%\uff09\u6807\u51c6\uff23\uff0b\u4e8c\u7ef4\u6570\u7ec4\uff0b\u975e\u9012\u5f52\u5b9e\u73b0\u4e94\u5b50\u68cb\u6e38\u620f_\u53ea\u7528\u4e8c\u7ef4\u6570\u7ec4\u4e0d\u7528\u9012\u5f52...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9141"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=9141"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9141\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=9141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=9141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=9141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}