#include <iostream>
#include <list>

using namespace std;

struct Coords
{
    Coords(int x_, int y_) : x(x_), y(y_) {}
    int x;
    int y;
};

struct Noeud
{
    Coords pos;
    int cout;
    int couth;
    Coords parent;
};

list<Noeud> liste_ouverte;
list<Noeud> liste_fermee;

Coords depart(0, 0);
Coords arrivee(9, 9);

bool dansListe(const list<Noeud> &liste, const Noeud &noeud, Noeud &nntmp = 0)
{
    for(int i = 0; i < liste.size(); i++)
    {
        if(liste[i] == noeud)
        {
            if(nntmp != 0)
                nntmp = liste[i];
            return true;
        }
        else
            continue;
    }
    return false;
}

void ajouter_cases_adjacentes(list<Noeud> &liste, const Noeud &noeud)
{
    Coords ctmp;
    Noeud ntmp;

    ctmp.x = noeud.pos.x - 1;
    ctmp.y = noeud.pos.y;
    ntmp.pos = ctmp;
    if(!(ctmp.x < 0 || ctmp.y < 0 || ctmp.x > 9 || ctmp.y > 9 || dansListe(liste_fermee, ntmp)))
    {
        ntmp.parent = noeud;
        ntmp.couth = ntmp.parent.couth + 1;
        ntmp.cout = (abs(arrivee.x - ntmp.parent.pos.x) + abs(arrivee.y - ntmp.parent.pos.y)) + ntmp.couth;
        if(dansListe(liste_ouverte, ntmp, nntmp))
        {
            if(ntmp.cout < nntmp.cout)
            {



int main()
{
    char tableau[10][10] = {
                            {0, 1, 0, 0, 0, 1, 1, 1, 1, 0},
                            {0, 1, 0, 1, 0, 1, 1, 1, 1, 0},
                            {0, 1, 0, 1, 0, 1, 1, 1, 1, 0},
                            {0, 1, 0, 1, 0, 1, 0, 0, 0, 0},
                            {0, 1, 0, 1, 0, 1, 0, 1, 1, 0},
                            {0, 1, 0, 1, 0, 1, 0, 0, 1, 0},
                            {0, 1, 0, 1, 0, 1, 1, 0, 1, 0},
                            {0, 1, 0, 1, 0, 1, 0, 0, 1, 0},
                            {0, 1, 0, 1, 0, 1, 0, 1, 1, 0},
                            {0, 0, 0, 1, 0, 0, 0, 1, 1, 0}
                           };

    Noeud ndebut;
    ndebut.pos = depart;
    ndebut.parent = 0;
    ndebut.couth = 0;

    liste_fermee.push_back(ndebut);

    ajouter_cases_adjacentes(liste_ouverte, ndebut);
