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