|
|
@ -1,21 +1,31 @@ |
|
|
|
#define _CRT_SECURE_NO_WARNINGS |
|
|
|
#define re return |
|
|
|
#define N 40 |
|
|
|
#define N 20 |
|
|
|
#include<stdio.h> |
|
|
|
#include<string.h> |
|
|
|
#include<stdlib.h> |
|
|
|
#include<time.h> |
|
|
|
#include<stdbool.h> |
|
|
|
|
|
|
|
void Apfel(int realU[N][N]); |
|
|
|
void Umgebung(char str[N][N]); |
|
|
|
void delay(int ms); |
|
|
|
|
|
|
|
int main(){ |
|
|
|
srand(time(0)); |
|
|
|
char str[N][N]; |
|
|
|
for (int i=0;i<N;i++){ |
|
|
|
for(int j=0;j<N;j++){ |
|
|
|
str[i][j]='0'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int realU[N][N]; |
|
|
|
printf("geben Sie die Richtung: ") ; |
|
|
|
char g=getchar(); |
|
|
|
Apfel(realU); |
|
|
|
|
|
|
|
if(g!=EOF){ |
|
|
|
//while(true){ |
|
|
@ -36,23 +46,13 @@ void Umgebung(char str[N][N]){ |
|
|
|
int realU[N][N]; |
|
|
|
system("cls"); |
|
|
|
printf("\n"); |
|
|
|
printf("\t\tHerzlichen Willkommen zum Spiel \n"); |
|
|
|
printf("\tHerzlichen Willkommen zum Spiel \n"); |
|
|
|
printf("\n"); |
|
|
|
|
|
|
|
for (int i=0;i<=N;i++){ |
|
|
|
for(int j=0;j<=N;j++){ |
|
|
|
if((i==0)||(j==0)||(i==N)||(j==N)){ |
|
|
|
str[i][j]= '+'; |
|
|
|
printf("%c ",str[i][j]);} |
|
|
|
else {str[i][j]= ' '; |
|
|
|
realU[i][j]=0; |
|
|
|
realU[1][1]=1; |
|
|
|
realU[1][2]=2; |
|
|
|
realU[1][3]=3; |
|
|
|
realU[1][4]=4; |
|
|
|
printf("%c",str[i][j]); |
|
|
|
printf("%d",realU[i][j]); |
|
|
|
} |
|
|
|
for (int i=0;i<N;i++){ |
|
|
|
for(int j=0;j<N;j++){ |
|
|
|
printf("%c ",str[i][j]); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\n"); |
|
|
|
} |
|
|
@ -60,3 +60,17 @@ void Umgebung(char str[N][N]){ |
|
|
|
printf("\n"); |
|
|
|
|
|
|
|
} |
|
|
|
void Apfel(int realU[N][N]){ |
|
|
|
int ii,jj; |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
ii=rand() % N; |
|
|
|
jj=rand() % N; |
|
|
|
if(realU[ii][jj]==0){ |
|
|
|
realU[ii][jj]=(N*N)+1; |
|
|
|
re; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |