Ślęcze nad tym algorytmem i wymyśliłem takie coś:
#include<iostream.h>
#include<string.h>
using namespace std;
int main()
{
int labirynt[11][11];
char lab;
string labir;
while(cin>>labir) //dopóki wczytuje labirynty
{
cout<<labir[0]<<endl; //wczytaj labirynt
int x=0,y=0;
for(x=0;x<10;x++) //wczytuje do tablicy labirynt ze stringa
{
for(y=0;y<10;y++)
{
if(labir[x*10+y]=='X')
{
labirynt[x][y]=1; //jesli sciana to 1
}
if(labir[x*10+y]=='O') //jesli korytarz to 0
{
labirynt[x][y]=0;
}
}
}
int poz=0,wiersz=0;
int iks=0,igrek=0;
while((iks!=9)&&(igrek!=9)) //dopóki nie jest na wyjsciu
{
if(igrek-1>-1)
{
if(labirynt[iks,igrek-1]==0)--igrek; //wprawo
}else if(iks+1<10)
{
if(labirynt[iks+1,igrek]==0)++iks; //front
}else if(igrek+1<10)
{
if(labirynt[iks,igrek+1]==0)++igrek; //w lewo
}else
{
cout<<'0'<<endl;break; /jesli brak wyjscia
}
}
cout<<'1'<<endl; //jesli jest wyjscie
}
return 0;
}
Ale nie działa [wstyd] </cpp>