Browse Source

Funktion lose

main
Jannis 2 years ago
parent
commit
a092be6985
  1. 28
      .vscode/tasks.json
  2. BIN
      src/Umgebung
  3. 41
      src/Umgebung.c

28
.vscode/tasks.json

@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc-11 build active file",
"command": "/usr/bin/gcc-11",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}

BIN
src/Umgebung

41
src/Umgebung.c

@ -139,4 +139,43 @@ void Apfel(int realU[N][N]){
re;
}
}
}
}
int lose(int realU[N][N], int realU1[N-1][N-1], char richtung){
int groesste = 0; //Suche den Kopf der Schlange
int ii, jj;
for(int i = 0; i < N ; i++){
for(int j = 0; j < N; j++){
if (realU1[i][j] > groesste){
groesste = realU1[i][j];
ii = i;
jj = j;
}
}
}
if(richtung == 'u'){
if(realU[ii - 1][jj] != 0){
return 1;
}
}
if(richtung == 'd'){
if(realU[ii + 1][jj] != N){
return 1;
}
}
if(richtung == 'l'){
if(realU[ii][jj-1] != 0){
return 1;
}
}
if(richtung == 'r'){
if(realU[ii][jj + 1] > N){
return 1;
}
}
return 0;
}
Loading…
Cancel
Save