77 lines
1.3 KiB
C
77 lines
1.3 KiB
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
int main(void) {
|
||
|
int tab[10][10]{{'x','x','x','x','x','x','x','x','x','x' },
|
||
|
{'x','x','x','x','x','x','x','x','x','x'},
|
||
|
{'x','x','x','x','x','x','x','x','x','x'},
|
||
|
{' ',' ',' ',' ',' ',' ',' ','x','x','x'},
|
||
|
{' ','x','x','x','x','x','x','x','x','x'},
|
||
|
{' ','x','x','x','x','x','x','x','x','x'},
|
||
|
{' ','x','x','x','x','x','x','x','x','x'},
|
||
|
{' ','x','x','x','x','x','x','x','x','x'},
|
||
|
{' ','x','x','x','x','x','x','x','x','x'},
|
||
|
{' ','x','x','x','x','x','x','x','x','x'} };
|
||
|
int x =7;
|
||
|
int y =4;
|
||
|
char direction;
|
||
|
int ysortie;
|
||
|
int xsortie;
|
||
|
int i;
|
||
|
|
||
|
|
||
|
|
||
|
for (i = 0; i<= i; i++){
|
||
|
printf("vers ou ? ");
|
||
|
scanf("%c", direction);
|
||
|
if(y == ysortie && x=xsortie){
|
||
|
return EXIT_SUCCESS;
|
||
|
}else if(direction == 'N'){
|
||
|
|
||
|
y+=1;
|
||
|
if (tab[y][x]=' '){
|
||
|
printf("ok");
|
||
|
}else{
|
||
|
printf("bloquer");
|
||
|
y-=1;
|
||
|
}
|
||
|
|
||
|
}else if(direction == 'S'){
|
||
|
|
||
|
y-=1;
|
||
|
if (tab[y][x]=' '){
|
||
|
printf("ok");
|
||
|
}else{
|
||
|
printf("bloquer");
|
||
|
y+=1;
|
||
|
}
|
||
|
}else if(direction == 'E'){
|
||
|
|
||
|
x+=1;
|
||
|
if (tab[y][x]=' '){
|
||
|
printf("ok");
|
||
|
}else{
|
||
|
printf("bloquer");
|
||
|
x-=1;
|
||
|
}
|
||
|
|
||
|
}else if(direction == 'O'){
|
||
|
|
||
|
x-=1;
|
||
|
if (tab[y][x]=' '){
|
||
|
printf("ok");
|
||
|
}
|
||
|
}else{
|
||
|
printf("bloquer");
|
||
|
x+=1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|