|
|
@ -1,4 +1,6 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdbool.h> |
|
|
|
|
|
|
|
|
|
|
|
int feld(char prifield[]) { |
|
|
|
|
|
|
@ -6,11 +8,11 @@ int feld(char prifield[]) { |
|
|
|
int numcoor[10]; |
|
|
|
char letcoor[10] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' }; |
|
|
|
|
|
|
|
printf("--"); |
|
|
|
printf(" "); |
|
|
|
|
|
|
|
for (int k = 0; k <= 9; k++) { |
|
|
|
numcoor[k] = k + 1; |
|
|
|
printf("%d", numcoor[k]); |
|
|
|
printf(" %d ", numcoor[k]); |
|
|
|
} |
|
|
|
|
|
|
|
printf("\n"); |
|
|
@ -21,7 +23,7 @@ int feld(char prifield[]) { |
|
|
|
printf("%c-", letcoor[i]); |
|
|
|
|
|
|
|
for (int j = 0; j <= 9; j++) { |
|
|
|
printf("%c", prifield[a]); |
|
|
|
printf("[%c]", prifield[a]); |
|
|
|
a++; |
|
|
|
} |
|
|
|
|
|
|
@ -82,6 +84,7 @@ int multiplayer() { |
|
|
|
|
|
|
|
char letco; |
|
|
|
int numco, coor; |
|
|
|
int score1, score2; |
|
|
|
|
|
|
|
for (int i = 0; i <= 99; i++) { |
|
|
|
|
|
|
@ -121,7 +124,7 @@ int multiplayer() { |
|
|
|
{ |
|
|
|
|
|
|
|
printf("Player 1, platziere deine Schiffe.\nKoordinate: "); |
|
|
|
scanf("%c%d", &letco, &numco); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -139,17 +142,44 @@ int multiplayer() { |
|
|
|
{ |
|
|
|
|
|
|
|
printf("Player 2, platziere deine Schiffe.\nKoordinate: "); |
|
|
|
scanf("%c%d", &letco, &numco); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[50] = 'X'; |
|
|
|
ships1[coor] = 'X'; |
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
k2++; |
|
|
|
|
|
|
|
} while (k2 < 17); |
|
|
|
|
|
|
|
printf("\n\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
!feld(player1); |
|
|
|
|
|
|
|
while (score1<16 !! score2 < 16) { |
|
|
|
|
|
|
|
!feld(player1); |
|
|
|
printf("Gib eine Zielkoordinate ein: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (player1[coor] == ships2[coor]) { |
|
|
|
player1[coor] = 'X'; |
|
|
|
score1 += 1; |
|
|
|
printf("Treffer!!\n"); |
|
|
|
} |
|
|
|
else { |
|
|
|
player[coor] = '-' |
|
|
|
printf("Kein Treffer.\n") |
|
|
|
} |
|
|
|
!feld(player1); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|