From d793d1bbefeb17c62e6a52924e8b27d5d0595797 Mon Sep 17 00:00:00 2001 From: fdai7729 Date: Fri, 9 Feb 2024 03:47:29 +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 c5a882a..17bc5e6 100644 --- a/src/main/c/Template/Battleship_game.c +++ b/src/main/c/Template/Battleship_game.c @@ -278,6 +278,67 @@ int* coorgenerator() { } } + shipcoor[5] = co; + + shipdirect = rand() % 2; + + if (a == 1) { + if (shipdirect == 0) { + for (int i = 6; i < 9; i++) { + co -= 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 6; i < 9; i++) { + co -= 10; + shipcoor[i] = co; + } + } + } + if (a == 2) { + if (shipdirect == 0) { + for (int i = 6; i < 9; i++) { + co -= 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 6; i < 9; i++) { + co += 10; + shipcoor[i] = co; + } + } + } + if (a == 3) { + if (shipdirect == 0) { + for (int i = 6; i < 9; i++) { + co += 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 6; i < 9; i++) { + co -= 10; + shipcoor[i] = co; + } + } + } + if (a == 4) { + if (shipdirect == 0) { + for (int i = 6; i < 9; i++) { + co += 1; + shipcoor[i] = co; + } + } + if (shipdirect == 1) { + for (int i = 6; i < 9; i++) { + co += 10; + shipcoor[i] = co; + } + } + } + return returnarr; }