IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

erreur structure je pense


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Par défaut erreur structure je pense
    Bonjour,

    Quand je compile, il semble que ma structure ne soit pas reconnu, donc j'ai des erreurs un peu partout. Pourtant j'ai bien mis ma structure au dessus des protos !

    Voici le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
     
    #include <stdio.h>
    #include <stdlib.h>
     
    // CONSTANTE ///////////////////////////////////////////////////////////////////
    #define T 31
    #define INFINI 999999
     
    // STRUCTURE DU NOEUD //////////////////////////////////////////////////////////
    typedef struct 
    {
        int marque;
        int est_marque;            // O pour noeud non marqué et 1 pour noeud marqué
        int predecesseur;
    }type_noeud;
     
    // PROTOTYPE ///////////////////////////////////////////////////////////////////
    type_noeud dijkstra                         ( int **matrice, type_noeud noeud_initialise[31], int indice_sommet_suivant );
    type_noeud initialisation_structure_noeud   ( type_noeud noeud_vierge[31]                                               );
          void   affichage_matrice              ( int **matrice                                                             );
           int **allocation_matrice             ( int **matrice                                                             );
           int **initialisation_matrice         ( int **matrice                                                             );
           int **remplissage_matrice            ( int **matrice                                                             );
           int   noeud_suivant                  ( type_noeud noeud[31]                                                      );
           int   maj_marque                     ( int **matrice, type_noeud noeud[31], int indice_noeud_suivant             );
     
    // FONCTION PRINCIPALE /////////////////////////////////////////////////////////
    int main (void)
    {
     
        int **matrice_vierge      = malloc                 ( T*sizeof(int *)     );
        int **matrice_allouee     = allocation_matrice     ( matrice_vierge      ); // ALLOCATION MEMOIRE POUR LA MATRICE 
        int **matrice_initialisee = initialisation_matrice ( matrice_allouee     ); // INITIALISATION DE LA MATRICE 
        int **matrice             = remplissage_matrice    ( matrice_initialisee ); // REMPLISSAGE DE LA MATRICE 
     
        affichage_matrice(matrice); // AFFICHAGE MATRICE 
     
        type_noeud noeud_vierge[31];
        type_noeud noeud_initialise[31]      = initialisation_structure_noeud ( noeud_vierge[31] ); // INITIALISATION DU NOEUD DE DEPART ET DE SON TABLEAU
     
        int indice_sommet_suivant;
        type_noeud noeud[31] = dijkstra( matrice, noeud_initialise[31], indice_sommet_suivant );
     
     
        getch();
     
    }
     
     
    // FONCTIONS ///////////////////////////////////////////////////////////////////
     
    int **allocation_matrice(int **matrice)
    {
     
          int i;
          for ( i=1 ; i < T ; i++)
              {
                 matrice[i]=malloc( T*sizeof(int) );
              }  
          return matrice;
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int **initialisation_matrice(int **matrice)
    {
     
         int i, j;
         for ( i=1 ; i<T ; i++ )
             {
                   for ( j=1 ; j<T ; j++ )
                       {
                            matrice[i][j]=INFINI;
                       }
     
                    if ( i==j )
                       {
                          matrice[i][j]=0; // On met à 0 la diagonale
                       }    
             }
     
             return matrice;
     
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int **remplissage_matrice(int **matrice)
    {
     
         matrice[1][13]=7;
         matrice[13][1]=7;
         matrice[1][2]=10;
         matrice[2][1]=10;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[2][6]=3; 
         matrice[6][2]=3;
         matrice[2][22]=4;
         matrice[22][2]=4;
         matrice[2][7]=5;
         matrice[7][2]=5;
         matrice[2][3]=4;
         matrice[3][2]=4;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[3][7]=9;
         matrice[7][3]=9;
         matrice[3][4]=2;
         matrice[4][3]=2;
         matrice[4][10]=5;    
         matrice[10][4]=5;
         matrice[4][5]=2;
         matrice[5][4]=2;
         matrice[5][10]=15;
         matrice[10][5]=15;
         matrice[10][7]=3;
         matrice[7][10]=3;
         matrice[10][15]=10;
         matrice[15][10]=10;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[7][9]=2;
         matrice[9][7]=2;
         matrice[7][22]=7;
         matrice[22][7]=7;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[22][9]=5;
         matrice[9][22]=5;
         matrice[22][6]=4;
         matrice[6][22]=4;
         matrice[6][23]=4;
         matrice[23][6]=4;
         matrice[6][13]=3;
         matrice[13][6]=3;
         matrice[13][23]=22;
         matrice[23][13]=22;
         matrice[8][13]=5;
         matrice[13][8]=5;
         matrice[13][14]=4;
         matrice[14][13]=4;
         matrice[14][16]=3;
         matrice[16][14]=3;
         matrice[14][12]=2;
         matrice[12][14]=2;
         matrice[14][24]=7;
         matrice[24][14]=7;
         matrice[8][16]=2;
         matrice[16][8]=2;
         matrice[23][24]=12;
         matrice[24][23]=12;
         matrice[9][11]=15;
         matrice[11][9]=15;
         matrice[9][15]=21;
         matrice[15][9]=21;
         matrice[15][17]=12;
         matrice[17][15]=12;
         matrice[16][19]=7;
         matrice[19][16]=7;
         matrice[16][12]=3;
         matrice[12][16]=3;
         matrice[12][18]=5;
         matrice[18][12]=5;
         matrice[12][24]=2;
         matrice[24][12]=2;
         matrice[24][25]=6;
         matrice[25][24]=6;
         matrice[24][11]=4;
         matrice[11][24]=4;
         matrice[11][20]=8;
         matrice[20][11]=8;
         matrice[11][17]=9;
         matrice[17][11]=9;
         matrice[17][21]=3;
         matrice[21][17]=3;
         matrice[21][30]=22;
         matrice[30][21]=22;
         matrice[21][20]=8;
         matrice[20][21]=8;
         matrice[20][29]=9;
         matrice[29][20]=9;
         matrice[20][25]=5;
         matrice[25][20]=5;
         matrice[25][28]=7;
         matrice[28][25]=7;
         matrice[25][18]=12;
         matrice[18][25]=12;
         matrice[18][27]=5;
         matrice[27][18]=5;
         matrice[18][19]=8;
         matrice[19][18]=8;
         matrice[19][26]=9;
         matrice[26][19]=9;
         matrice[26][27]=5;
         matrice[27][26]=5;
         matrice[27][28]=5;
         matrice[28][27]=5;
         matrice[28][29]=5;
         matrice[29][28]=5;
         matrice[29][30]=3;
         matrice[30][29]=3;
     
         return matrice;
     
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    void affichage_matrice(int **matrice)
    {
     
        int i, j;
        for ( i=1 ; i<T ; i++ )
            {
                  for ( j=1 ; j<T ; j++)
                      {
                            printf("\nmatrice[%d][%d]=%d", i, j, matrice[i][j]);
                      }
            }
     
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int noeud_suivant( type_noeud noeud[31] )
    {
        int indice_noeud_suivant=0;
        int max=INFINI;
     
        int i;
        for ( i=1 ; i<T ; i++ )
            {
                  if (( noeud[i].marque < max ) && ( noeud[i].est_marque == 0 ))
                     {
                                        max = noeud[i].marque;
                                        indice_noeud_suivant=1;
                     }
     
                  noeud[indice_noeud_suivant].est_marque=1;
                  return indice_noeud_suivant;
            }
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int maj_marque( int **matrice, type_noeud noeud[31], int indice_noeud_suivant )
      {
     
          int temporaire;
     
          int i;
          for( i=1 ; i<T ;i++ )
          {
                            if ( matrice[indice_noeud_suivant][i] != INFINI )
                               {
                                        temporaire=0;
                                        temporaire=noeud[indice_noeud_suivant].marque + matrice[indice_noeud_suivant][i];                   
     
                                        if ( temporaire < noeud[i].marque )
                                           {
                                                        noeud[i].marque = temporaire;
                                                        noeud[i].predecesseur = indice_noeud_suivant;
                                           }
                               }
          }
      }        
    ////////////////////////////////////////////////////////////////////////////////
     
    type_noeud initialisation_structure_noeud( type_noeud noeud_vierge[31] )
    {
     
               int i;
               for( i=1 ; i <T ; i++ )
               {
                   noeud_vierge[i].marque=INFINI;
                   noeud_vierge[i].est_marque=0;          
               }  
     
               noeud_vierge[1].marque=0;
               noeud_vierge[1].est_marque=1;
               noeud_vierge[1].predecesseur=-1;
     
               return noeud_vierge[31];
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    type_noeud dijkstra( int **matrice, type_noeud noeud_initialise[31], int indice_sommet_suivant )
    {
     
               int control=1;
               while ( control != 30 )
                     {
                               maj_marque( matrice, noeud_initialise[31], indice_sommet_suivant );
                               indice_sommet_suivant=noeud_suivant(noeud_initialise[31]);
                               control++;
                     }
     
                     return noeud_initialise[31];
    }
    Merci d'avance

  2. #2
    Expert confirmé

    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    10 610
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 10 610
    Billets dans le blog
    2
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Quand je compile, il semble que ma structure ne soit pas reconnu, donc j'ai des erreurs un peu partout. Pourtant j'ai bien mis ma structure au dessus des protos !
    Et quelle est la (ou les) premières erreurs ?

    Un petit apercu ne serait pas de trop..

    D'autre part, ceci est une mauvaise pratique :

    Plus une faute (pas de "_" dans noeud_initialise")

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    type_noeud dijkstra ( int **matrice, type noeud noeud_initialise[31], int indice_sommet_suivant );

    Pourquoi ne pas mettre :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    type_noeud dijkstra ( int **matrice, type_noeud *noeud_initialise, int nb_noeuds, int indice_sommet_suivant );
    ??

  3. #3
    Membre éclairé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Par défaut
    [EDIT] L'image d'origine est ici : http://zepload.com/images/1239040538_Sans titre.png

    exact j'avais pas vu erreur de fatigue.
    Donc j'ai recompilé et sur l'image vous pouvez voir les erreurs restantes mais je n'arrive pas à les corriger !

    Dans la fonction dijkstra j'ai une erreur sur les fonction utilisant le paramètre de type type_noeud et je ne comprends pas !? Encore un truk que j'ai pas intégré sur les tableaux je suppose :S

  4. #4
    Membre éclairé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    #include <stdio.h>
    #include <stdlib.h>
     
    // CONSTANTE ///////////////////////////////////////////////////////////////////
    #define T 31
    #define INFINI 999999
     
    // STRUCTURE DU NOEUD //////////////////////////////////////////////////////////
    typedef struct 
    {
        int marque;
        int est_marque;            // O pour noeud non marqué et 1 pour noeud marqué
        int predecesseur;
    }type_noeud;
     
    // PROTOTYPE ///////////////////////////////////////////////////////////////////
    type_noeud  *dijkstra                       ( int **matrice, type_noeud *noeud_initialise, int indice_sommet_suivant );
    type_noeud  *initialisation_structure_noeud ( type_noeud *noeud_vierge                                               );
          void   affichage_matrice              ( int **matrice                                                          );
           int **allocation_matrice             ( int **matrice                                                          );
           int **initialisation_matrice         ( int **matrice                                                          );
           int **remplissage_matrice            ( int **matrice                                                          );
           int   noeud_suivant                  ( type_noeud *noeud                                                      );
           int   maj_marque                     ( int **matrice, type_noeud *noeud, int indice_noeud_suivant             );
     
    // FONCTION PRINCIPALE /////////////////////////////////////////////////////////
    int main (void)
    {
     
        int **matrice_vierge      = malloc                 ( T*sizeof(int *)     );
        int **matrice_allouee     = allocation_matrice     ( matrice_vierge      ); // ALLOCATION MEMOIRE POUR LA MATRICE 
        int **matrice_initialisee = initialisation_matrice ( matrice_allouee     ); // INITIALISATION DE LA MATRICE 
        int **matrice             = remplissage_matrice    ( matrice_initialisee ); // REMPLISSAGE DE LA MATRICE 
     
        affichage_matrice(matrice); // AFFICHAGE MATRICE 
     
     
        type_noeud *noeud_vierge= malloc(T*sizeof(*noeud_vierge)); 
        type_noeud *noeud_initialise = initialisation_structure_noeud ( noeud_vierge ); // INITIALISATION DU NOEUD DE DEPART ET DE SON TABLEAU
     
        int indice_sommet_suivant;
        type_noeud *noeud = dijkstra( matrice, noeud_initialise, indice_sommet_suivant );
     
     
        getch();
     
    }
     
     
    // FONCTIONS ///////////////////////////////////////////////////////////////////
     
    int **allocation_matrice(int **matrice)
    {
     
          int i;
          for ( i=1 ; i < T ; i++)
              {
                 matrice[i]=malloc( T*sizeof(int) );
              }  
          return matrice;
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int **initialisation_matrice(int **matrice)
    {
     
         int i, j;
         for ( i=1 ; i<T ; i++ )
             {
                   for ( j=1 ; j<T ; j++ )
                       {
                            matrice[i][j]=INFINI;
                       }
     
                    if ( i==j )
                       {
                          matrice[i][j]=0; // On met à 0 la diagonale
                       }    
             }
     
             return matrice;
     
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int **remplissage_matrice(int **matrice)
    {
     
         matrice[1][13]=7;
         matrice[13][1]=7;
         matrice[1][2]=10;
         matrice[2][1]=10;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[2][6]=3; 
         matrice[6][2]=3;
         matrice[2][22]=4;
         matrice[22][2]=4;
         matrice[2][7]=5;
         matrice[7][2]=5;
         matrice[2][3]=4;
         matrice[3][2]=4;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[3][7]=9;
         matrice[7][3]=9;
         matrice[3][4]=2;
         matrice[4][3]=2;
         matrice[4][10]=5;    
         matrice[10][4]=5;
         matrice[4][5]=2;
         matrice[5][4]=2;
         matrice[5][10]=15;
         matrice[10][5]=15;
         matrice[10][7]=3;
         matrice[7][10]=3;
         matrice[10][15]=10;
         matrice[15][10]=10;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[7][9]=2;
         matrice[9][7]=2;
         matrice[7][22]=7;
         matrice[22][7]=7;
         matrice[2][13]=2;
         matrice[13][2]=2;
         matrice[22][9]=5;
         matrice[9][22]=5;
         matrice[22][6]=4;
         matrice[6][22]=4;
         matrice[6][23]=4;
         matrice[23][6]=4;
         matrice[6][13]=3;
         matrice[13][6]=3;
         matrice[13][23]=22;
         matrice[23][13]=22;
         matrice[8][13]=5;
         matrice[13][8]=5;
         matrice[13][14]=4;
         matrice[14][13]=4;
         matrice[14][16]=3;
         matrice[16][14]=3;
         matrice[14][12]=2;
         matrice[12][14]=2;
         matrice[14][24]=7;
         matrice[24][14]=7;
         matrice[8][16]=2;
         matrice[16][8]=2;
         matrice[23][24]=12;
         matrice[24][23]=12;
         matrice[9][11]=15;
         matrice[11][9]=15;
         matrice[9][15]=21;
         matrice[15][9]=21;
         matrice[15][17]=12;
         matrice[17][15]=12;
         matrice[16][19]=7;
         matrice[19][16]=7;
         matrice[16][12]=3;
         matrice[12][16]=3;
         matrice[12][18]=5;
         matrice[18][12]=5;
         matrice[12][24]=2;
         matrice[24][12]=2;
         matrice[24][25]=6;
         matrice[25][24]=6;
         matrice[24][11]=4;
         matrice[11][24]=4;
         matrice[11][20]=8;
         matrice[20][11]=8;
         matrice[11][17]=9;
         matrice[17][11]=9;
         matrice[17][21]=3;
         matrice[21][17]=3;
         matrice[21][30]=22;
         matrice[30][21]=22;
         matrice[21][20]=8;
         matrice[20][21]=8;
         matrice[20][29]=9;
         matrice[29][20]=9;
         matrice[20][25]=5;
         matrice[25][20]=5;
         matrice[25][28]=7;
         matrice[28][25]=7;
         matrice[25][18]=12;
         matrice[18][25]=12;
         matrice[18][27]=5;
         matrice[27][18]=5;
         matrice[18][19]=8;
         matrice[19][18]=8;
         matrice[19][26]=9;
         matrice[26][19]=9;
         matrice[26][27]=5;
         matrice[27][26]=5;
         matrice[27][28]=5;
         matrice[28][27]=5;
         matrice[28][29]=5;
         matrice[29][28]=5;
         matrice[29][30]=3;
         matrice[30][29]=3;
     
         return matrice;
     
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    void affichage_matrice(int **matrice)
    {
     
        int i, j;
        for ( i=1 ; i<T ; i++ )
            {
                  for ( j=1 ; j<T ; j++)
                      {
                            printf("\nmatrice[%d][%d]=%d", i, j, matrice[i][j]);
                      }
            }
     
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int noeud_suivant( type_noeud *noeud )
    {
        int indice_noeud_suivant=0;
        int max=INFINI;
     
        int i;
        for ( i=1 ; i<T ; i++ )
            {
                  if (( noeud[i].marque < max ) && ( noeud[i].est_marque == 0 ))
                     {
                                        max = noeud[i].marque;
                                        indice_noeud_suivant=1;
                     }
     
                  noeud[indice_noeud_suivant].est_marque=1;
                  return indice_noeud_suivant;
            }
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    int maj_marque( int **matrice, type_noeud *noeud, int indice_noeud_suivant )
      {
     
          int temporaire;
     
          int i;
          for( i=1 ; i<T ;i++ )
          {
                            if ( matrice[indice_noeud_suivant][i] != INFINI )
                               {
                                        temporaire=0;
                                        temporaire=noeud[indice_noeud_suivant].marque + matrice[indice_noeud_suivant][i];                   
     
                                        if ( temporaire < noeud[i].marque )
                                           {
                                                        noeud[i].marque = temporaire;
                                                        noeud[i].predecesseur = indice_noeud_suivant;
                                           }
                               }
          }
      }        
    ////////////////////////////////////////////////////////////////////////////////
     
    type_noeud *initialisation_structure_noeud( type_noeud *noeud_vierge )
    {
     
               int i;
               for( i=1 ; i <T ; i++ )
               {
                   noeud_vierge[i].marque=INFINI;
                   noeud_vierge[i].est_marque=0;          
               }  
     
               noeud_vierge[1].marque=0;
               noeud_vierge[1].est_marque=1;
               noeud_vierge[1].predecesseur=-1;
     
               return noeud_vierge;
    }
    ////////////////////////////////////////////////////////////////////////////////
     
    type_noeud *dijkstra( int **matrice, type_noeud *noeud_initialise, int indice_sommet_suivant )
    {
     
               int control=1;
               while ( control != 30 )
                     {
                               maj_marque( matrice, noeud_initialise, indice_sommet_suivant );
                               indice_sommet_suivant=noeud_suivant( noeud_initialise );
                               control++;
                     }
     
                     return noeud_initialise;
    }
    Bon en fait j'ai fais un malloc sur ma structure et ça marche mieux mais pas suffisament encore, je n'ai plus d'erreur de compilation mais à l'execution erreur windows mémoire ! Quelqu'un peut-il m'aider svp !?

    Merci d'avance

  5. #5
    Membre éclairé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Par défaut
    c'est bon c'est que j'ai oublié d'initialiser mon indice_sommet_suivant à 1 avant de lancer la fonction dijkstra

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. petit probleme de structure je pense
    Par masterix59 dans le forum C
    Réponses: 5
    Dernier message: 17/12/2007, 16h06
  2. [structures] Erreur structure vide
    Par emi3113 dans le forum MATLAB
    Réponses: 6
    Dernier message: 04/07/2007, 18h36
  3. [C# 1.1] Erreur GDI enfin je pense
    Par notalp dans le forum Windows Forms
    Réponses: 2
    Dernier message: 22/09/2006, 15h32
  4. Réponses: 20
    Dernier message: 11/07/2006, 17h11
  5. Erreur php je pense
    Par Anduriel dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 13/06/2005, 13h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo