#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 3
void Display(int *a, int mode)
{
int n = N * N;
while (n--) {
if (*a < mode)
else
++a;
if (n % N == 0)
}
}
int main()
{
int x,
y,
mine[N][N];/* 0:初期状態 1:マス目を選んで爆弾に当たらなかった場所 2:爆弾 */
for ( x = 0; x < N; ++x)
for ( y = 0; y < N; ++y)
mine[x][y] = 0;
// (a) 爆弾の数を 3 つにせよ(同じ場所に複数置かない)。
{
int n = 3;
while (n) {
if (mine[x][y] == 0) {
mine[x][y] = 2;
--n;
}
}
}
// Display(*mine,3); /* all display for debug */
{
int c = 6;/* Winまでの残り試行回数 */
while (1) {
Display(*mine, 2);
// (d) マス目の範囲から外れた数値を打ち込んだ場合に警告を出すようにする(試行の回数には含めない)。
while (1) {
if ((x >= 0) && (x < N) && (y >= 0) && (y < N))break;/* x, y is ok */
printf("マス目の範囲から外れています。\n正しい数値(x,y=0~3)を入力して下さい。\n" ); }
// (c) 一度選んだマス目は再度選べないようにする(試行の回数には含めない)。
if (mine[x][y] == 1)continue;
if (mine[x][y]==2) {
} else {
mine[x][y] = 1;
--c;
}
// (b) 6 回試行して爆弾を見つけなかった場合は、“You Win!” と表示してプログラムを終了する。
if (c == 0) {
}
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KI2RlZmluZSBOIDMKCnZvaWQgRGlzcGxheShpbnQgKmEsIGludCBtb2RlKQp7CiAgaW50IG4gPSBOICogTjsKICB3aGlsZSAobi0tKSB7CiAgICBpZiAoKmEgPCBtb2RlKQogICAgICBwcmludGYoIiVkIiwgKmEpOwogICAgZWxzZQogICAgICBwcmludGYoIiVkIiwgMCk7CiAgICArK2E7CiAgICBpZiAobiAlIE4gPT0gMCkKICAgICAgcHV0Y2hhcignXG4nKTsKICB9Cn0KCmludCBtYWluKCkKewogIGludCB4LAogICAgICB5LAogICAgICBtaW5lW05dW05dOy8qIDA65Yid5pyf54q25oWL44CAMTrjg57jgrnnm67jgpLpgbjjgpPjgafniIblvL7jgavlvZPjgZ/jgonjgarjgYvjgaPjgZ/loLTmiYDjgIAyOueIhuW8viAqLwoKICBzcmFuZCh0aW1lKE5VTEwpKTsKICBmb3IgKCB4ID0gMDsgeCA8IE47ICsreCkKICAgIGZvciAoIHkgPSAwOyB5IDwgTjsgKyt5KQogICAgICBtaW5lW3hdW3ldID0gMDsKCiAgLy8gKGEpIOeIhuW8vuOBruaVsOOCkiAzIOOBpOOBq+OBm+OCiCjlkIzjgZjloLTmiYDjgavopIfmlbDnva7jgYvjgarjgYQp44CCCiAgewogICAgaW50IG4gPSAzOwogICAgd2hpbGUgKG4pIHsKICAgICAgeCA9IHJhbmQoKSAlIE47CiAgICAgIHkgPSByYW5kKCkgJSBOOwogICAgICBpZiAobWluZVt4XVt5XSA9PSAwKSB7CiAgICAgICAgbWluZVt4XVt5XSA9IDI7CiAgICAgICAgLS1uOwogICAgICB9CiAgICB9CiAgfQoKICAvLyBEaXNwbGF5KCptaW5lLDMpOyAvKiBhbGwgZGlzcGxheSBmb3IgZGVidWcgKi8KCiAgewogICAgaW50IGMgPSA2Oy8qIFdpbuOBvuOBp+OBruaui+OCiuippuihjOWbnuaVsCAqLwogICAgd2hpbGUgKDEpIHsKICAgICAgRGlzcGxheSgqbWluZSwgMik7CgogICAgICAvLyAoZCkg44Oe44K555uu44Gu56+E5Zuy44GL44KJ5aSW44KM44Gf5pWw5YCk44KS5omT44Gh6L6844KT44Gg5aC05ZCI44Gr6K2m5ZGK44KS5Ye644GZ44KI44GG44Gr44GZ44KLKOippuihjOOBruWbnuaVsOOBq+OBr+WQq+OCgeOBquOBhCnjgIIKICAgICAgd2hpbGUgKDEpIHsKICAgICAgICBwcmludGYoIlg6ICIpOwogICAgICAgIHNjYW5mKCIlZCIsICZ4KTsKICAgICAgICBwcmludGYoIlk6ICIpOwogICAgICAgIHNjYW5mKCIlZCIsICZ5KTsKICAgICAgICBpZiAoKHggPj0gMCkgJiYgKHggPCBOKSAmJiAoeSA+PSAwKSAmJiAoeSA8IE4pKWJyZWFrOy8qIHgsIHkgaXMgb2sgKi8KICAgICAgICBwcmludGYoIuODnuOCueebruOBruevhOWbsuOBi+OCieWkluOCjOOBpuOBhOOBvuOBmeOAglxu5q2j44GX44GE5pWw5YCkKHgseT0wfjMp44KS5YWl5Yqb44GX44Gm5LiL44GV44GE44CCXG4iICk7CiAgICAgIH0KCiAgICAgIC8vIChjKSDkuIDluqbpgbjjgpPjgaDjg57jgrnnm67jga/lho3luqbpgbjjgbnjgarjgYTjgojjgYbjgavjgZnjgoso6Kmm6KGM44Gu5Zue5pWw44Gr44Gv5ZCr44KB44Gq44GEKeOAggogICAgICBpZiAobWluZVt4XVt5XSA9PSAxKWNvbnRpbnVlOwoKICAgICAgaWYgKG1pbmVbeF1beV09PTIpIHsKICAgICAgICBwcmludGYoIldoYW0hXG4iKTsKICAgICAgICBleGl0KDApOwogICAgICB9IGVsc2UgewogICAgICAgIHByaW50ZigiWW91IGFyZSBzYWZlLlxuIik7CiAgICAgICAgbWluZVt4XVt5XSA9IDE7CiAgICAgICAgLS1jOwogICAgICB9CiAgICAgIC8vIChiKSA2IOWbnuippuihjOOBl+OBpueIhuW8vuOCkuimi+OBpOOBkeOBquOBi+OBo+OBn+WgtOWQiOOBr+OAgeKAnFlvdSBXaW4h4oCdIOOBqOihqOekuuOBl+OBpuODl+ODreOCsOODqeODoOOCkue1guS6huOBmeOCi+OAggogICAgICBpZiAoYyA9PSAwKSB7CiAgICAgICAgcHJpbnRmKCJZb3UgV2luIVxuIik7CiAgICAgICAgZXhpdCgwKTsKICAgICAgfQogICAgfQogIH0KCiAgcmV0dXJuIDA7Cn0K