From 3badada5dac81e403a630df472c1195060a01bea Mon Sep 17 00:00:00 2001 From: fdai7729 Date: Fri, 9 Feb 2024 03:42:32 +0000 Subject: [PATCH] Update src/main/c/Template/Battleship_game.c --- src/main/c/Template/Battleship_game.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/c/Template/Battleship_game.c b/src/main/c/Template/Battleship_game.c index 50d9322..f566d42 100644 --- a/src/main/c/Template/Battleship_game.c +++ b/src/main/c/Template/Battleship_game.c @@ -68,6 +68,24 @@ int convertcoor(char a, int b) { return co; } +int* coorgenerator() { + + int randomcoor[100] = {44, 45, 55, 54, 53, 43, 33, 34, 35, 36, 46, 56, 66, 65, 64, 63, 62, 52, 42, 32, 22, 23, 24, 25, 26, 27, 37, 47, 57, 67, 77, 76, 75, 74, 73, 72, 71, 61, 51, 41, 31, 21, 11, 12, 13, 14, 15, 16, 17, 18, 28, 38, 48, 58, 68, 78, 88, 87, 86, 85, 84, 83, 82, 81, 80, 70, 60, 50, 40, 30, 20, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90}; + int shipcoor[17]; + int* shipcoorptr[17]; + int co, vers, direct; + int a = 0; + + int* returnarr = (int*)malloc(17* sizeof(int)); + + if (returnarr == NULL) { + perror("Memory allocation failed"); + exit(1); + } + + return returnarr; +} + int hitgenerator() { int hit;