From e44039430c40bc3266bae52dac6ff8410eb71f61 Mon Sep 17 00:00:00 2001 From: fdai7729 Date: Fri, 9 Feb 2024 03:43:32 +0000 Subject: [PATCH] Update src/main/c/Template/Battleship_game.c --- src/main/c/Template/Battleship_game.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/c/Template/Battleship_game.c b/src/main/c/Template/Battleship_game.c index f566d42..1a4774b 100644 --- a/src/main/c/Template/Battleship_game.c +++ b/src/main/c/Template/Battleship_game.c @@ -83,6 +83,30 @@ int* coorgenerator() { exit(1); } + srand(time(NULL)); + + //(5)-er + + int ranco = rand() % 4; + + co = randomcoor[ranco]; + + int ranvers = rand()%5; + int randirect = rand()%4; + + if (randirect == 0) { + co = co + ranvers; + } + if (randirect == 1) { + co = co - ranvers; + } + if (randirect == 2) { + co = co + 10*ranvers; + } + if (randirect == 3) { + co = co - 10*ranvers; + } + return returnarr; }