From bd64d0b512549c8535896b7f0e4717ae78c0fbb5 Mon Sep 17 00:00:00 2001 From: fdai7729 Date: Fri, 9 Feb 2024 03:44:49 +0000 Subject: [PATCH] Update src/main/c/Template/Battleship_game.c --- src/main/c/Template/Battleship_game.c | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/main/c/Template/Battleship_game.c b/src/main/c/Template/Battleship_game.c index 40cc468..7caf6ef 100644 --- a/src/main/c/Template/Battleship_game.c +++ b/src/main/c/Template/Battleship_game.c @@ -75,6 +75,67 @@ int feld(char prifield[]) { } } + shipcoor[0] = co; + + int shipdirect = rand() % 2; + + if (a == 1) { + if (shipdirect == 0) { + for (int i = 1; i < 5; i++) { + co -= 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 1; i < 5; i++) { + co -= 10; + shipcoor[i] = co; + } + } + } + if (a == 2) { + if (shipdirect == 0) { + for (int i = 1; i < 5; i++) { + co -= 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 1; i < 5; i++) { + co += 10; + shipcoor[i] = co; + } + } + } + if (a == 3) { + if (shipdirect == 0) { + for (int i = 1; i < 5; i++) { + co += 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 1; i < 5; i++) { + co -= 10; + shipcoor[i] = co; + } + } + } + if (a == 4) { + if (shipdirect == 0) { + for (int i = 1; i < 5; i++) { + co += 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 1; i < 5; i++) { + co += 10; + shipcoor[i] = co; + } + } + } + return 0; }