From 0ed97a74cee4a5c05e465e98d66de3dd55fecf0b Mon Sep 17 00:00:00 2001 From: fdai7729 Date: Fri, 9 Feb 2024 03:44:10 +0000 Subject: [PATCH] Update src/main/c/Template/Battleship_game.c --- src/main/c/Template/Battleship_game.c | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/main/c/Template/Battleship_game.c b/src/main/c/Template/Battleship_game.c index 1a4774b..40cc468 100644 --- a/src/main/c/Template/Battleship_game.c +++ b/src/main/c/Template/Battleship_game.c @@ -31,6 +31,50 @@ int feld(char prifield[]) { printf("\n"); } + ranvers = rand() % 5; + int randirect2 = rand() % 2; + + if (randirect == 0) { + if (randirect2 == 0) { + co = co + 10 * ranvers; + a = 1; + } + if (randirect2 == 1) { + co = co - 10 * ranvers; + a = 2; + } + } + if (randirect == 1) { + if (randirect == 0) { + co = co + 10 * ranvers; + a = 3; + } + if (randirect == 0) { + co = co - 10 * ranvers; + a = 4; + } + } + if (randirect == 2) { + if (randirect == 0) { + co = co + ranvers; + a = 1; + } + if (randirect == 0) { + co = co - ranvers; + a = 3; + } + } + if (randirect == 3) { + if (randirect == 0) { + co = co + ranvers; + a = 2; + } + if (randirect == 0) { + co = co - ranvers; + a = 4; + } + } + return 0; }