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 :

problème en programmant le modèle PERT


Sujet :

C

  1. #1
    Membre du Club Avatar de scofild20
    Inscrit en
    Mars 2007
    Messages
    109
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 109
    Points : 47
    Points
    47
    Par défaut problème en programmant le modèle PERT
    bonjour , j'ai comme projet de programmer le modèle PERT , j'ai suivi l'algorithme mais le resultat n'est pas satisfaisant , voici la partie du code ou existe la problème :
    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
    int estvide(int col, char **m, int n )
    {
        int Test=1; int i=0;
     
        while (Test==1 && i<n)
        {
              if (m[i][col]=='*')  Test=0;
              else i++;
        }
     
        return Test;
     
    }
     
    void supprimer( int lig, char **m, int n)
    {
         for (int j=0;j<n;j++) m[lig][j]='@';
     
    }
    int existezero(int t[],int n)
    {
        int trouve=0;
        int i=0;
            while(i<n && trouve==0)
            {
                      if (t[i]==0) trouve=1;
                      else i++;
            }
     
        return trouve;
     
    }
     
     
    void RemplirPlusTOT (char **m, int n, int RPTOT[], int *rangMaxi)
    {
         int i,j;
         for (i=0;i<n;i++) RPTOT[i]=0;
         *rangMaxi=1;
     
     
         do {
             for (j=0;j<n;j++)
             {
                 if ( estvide(j,m,n)==1 && RPTOT[j]==0)
                 {
                                       RPTOT[j]=(*rangMaxi);
                                       supprimer(j,m,n);
                 }
             }
             printf("\n testing ..\n"); // lors de ce test la boucle do tourne seulement 2 fois 
             (*rangMaxi)=(*rangMaxi)+1; // donc le max des rang je l'ai est 2 et c'est faux 
             } while (existezero(RPTOT,n)==1); /*la problème alors existe existezero()*/
     
     
    }
    quelqu'un peut m'aidez ??

  2. #2
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par scofild20 Voir le message
    bonjour , j'ai comme projet de programmer le modèle PERT , j'ai suivi l'algorithme mais le resultat n'est pas satisfaisant , voici la partie du code ou existe la problème :
    Euh, c'est quoi le modèle PERT ? On est pas omniscients..., on est pas dans ta tête... Et si tu as un problème d'algo, c'est pas ici...

    Ton code présentable et compilable correctement :
    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
     
    #include <stdio.h>
     
    int estvide (int col, char **m, int n)
    {
       int Test = 1;
       int i = 0;
     
       while (Test == 1 && i < n)
       {
          if (m[i][col] == '*')
             Test = 0;
          else
             i++;
       }
     
       return Test;
     
    }
     
    void supprimer (int lig, char **m, int n)
    {
       int j;
       for (j = 0; j < n; j++)
          m[lig][j] = '@';
     
    }
    int existezero (int t[], int n)
    {
       int trouve = 0;
       int i = 0;
       while (i < n && trouve == 0)
       {
          if (t[i] == 0)
             trouve = 1;
          else
             i++;
       }
     
       return trouve;
     
    }
     
    void RemplirPlusTOT (char **m, int n, int RPTOT[], int *rangMaxi)
    {
       int i, j;
       for (i = 0; i < n; i++)
          RPTOT[i] = 0;
       *rangMaxi = 1;
     
       do
       {
          for (j = 0; j < n; j++)
          {
             if (estvide (j, m, n) == 1 && RPTOT[j] == 0)
             {
                RPTOT[j] = (*rangMaxi);
                supprimer (j, m, n);
             }
          }
          printf ("\n testing ..\n"); // lors de ce test la boucle do tourne seulement 2 fois
          (*rangMaxi) = (*rangMaxi) + 1; // donc le max des rang je l'ai est 2 et c'est faux
       }
       while (existezero (RPTOT, n) == 1); /*la problème alors existe existezero() */
     
    }
     
    int main (void)
    {
       return 0;
    }
    Il faut maintenant que tu fournisses le code d'appel avec une explication sur le but de la chose.

  3. #3
    Membre du Club Avatar de scofild20
    Inscrit en
    Mars 2007
    Messages
    109
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 109
    Points : 47
    Points
    47
    Par défaut
    Il faut maintenant que tu fournisses le code d'appel avec une explication sur le but de la chose.
    ok voici le code d'appel
    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
     
    int main()
    {
     
    char **m, **mat; int n;
    int *rang,*tab_date;
    int i;
     
    int rangMaxi;
     
    printf("\n Donner la taille de la matrice  :");
     
    scanf("%d", &n);
     
    m= new char*[n] ;  
     
    mat=new char*[n];
     
    rang=new int[n];
     
       for (i=0; i<n;i++)   m[i]=new char[n];
     
     
    auto_saisie(m);
    RemplirPlusTOT(m,n,rang,&rangMaxi);
    le but est de founrnin un tableau rang[] avec les rang des colonne dans la matrice , mais concentrant sur le code

    j'ai deja l'algo pret j'ai juste traduit en langage c , lors de la traduction il peut y avoir des erreurs de pointeur ou autre choses, c'est ce que je veux vérifier avec vous .

  4. #4
    Membre du Club Avatar de scofild20
    Inscrit en
    Mars 2007
    Messages
    109
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 109
    Points : 47
    Points
    47
    Par défaut
    voici le code complet pour le test avec devc++

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <malloc.h>
    int estvide(int col, char **m, int n )
    {
        int Test=1; int i=0;
     
        while (Test==1 && i<n)
        {
              if (m[i][col]=='*')  Test=0;
              else i++;
        }
     
        return Test;
     
    }
     
    void supprimer( int lig, char **m, int n)
    {
         for (int j=0;j<n;j++) m[lig][j]='@';
     
    }
    int existezero(int t[],int n)
    {
        int trouve=0;
        int i=0;
            while(i<n && trouve==0)
            {
                      if (t[i]==0) trouve=1;
                      else i++;
            }
     
        return trouve;
     
    }
     
     
    void RemplirPlusTOT (char **m, int n, int RPTOT[], int *rangMaxi)
    {
         int i,j;
         for (i=0;i<n;i++) RPTOT[i]=0;
         *rangMaxi=1;
     
     
         do {
             for (j=0;j<n;j++)
             {
                 if ( estvide(j,m,n)==1 && RPTOT[j]==0)
                 {
                                       RPTOT[j]=(*rangMaxi);
                                       supprimer(j,m,n);
                 }
             }
             printf("\n testing ..\n"); // lors de ce test la boucle do tourne seulement 2 fois 
             (*rangMaxi)=(*rangMaxi)+1; // donc le max des rang je l'ai est 2 et c'est faux 
             } while (existezero(RPTOT,n)==1); // la problème alors existe existezero()
     
     
    }
     
     
    void reverse_matrice(char **m, int n, char **mat)
    {
     
     
         //printf("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\n");
         for (int i=0 ; i < n ; i++)
             for (int j=0;j<n;j++)
             {
                 mat[i][j]=m[j][i];
             }
     
     
    }
     
     
     
     
     
     
     
     
    void auto_saisie(char **matrice)
    {
    matrice[0][0]='@';
    matrice[0][1]='*';
    matrice[0][2]='*';
    matrice[0][3]='*';
    matrice[0][4]='@';
    matrice[0][5]='*';
    matrice[0][6]='*';
    matrice[0][7]='@';
    matrice[1][0]='@';
    matrice[1][1]='@';
    matrice[1][2]='@';
    matrice[1][3]='@';
    matrice[1][4]='@';
    matrice[1][5]='@';
    matrice[1][6]='@';
    matrice[1][7]='@';
    matrice[2][0]='@';
    matrice[2][1]='*';
    matrice[2][2]='@';
    matrice[2][3]='@';
    matrice[2][4]='@';
    matrice[2][5]='@';
    matrice[2][6]='*';
    matrice[2][7]='*';
    matrice[3][0]='@';
    matrice[3][1]='@';
    matrice[3][2]='@';
    matrice[3][3]='@';
    matrice[3][4]='@';
    matrice[3][5]='@';
    matrice[3][6]='@';
    matrice[3][7]='@';
    matrice[4][0]='@';
    matrice[4][1]='*';
    matrice[4][2]='@';
    matrice[4][3]='@';
    matrice[4][4]='@';
    matrice[4][5]='@';
    matrice[4][6]='*';
    matrice[4][7]='*';
    matrice[5][0]='@';
    matrice[5][1]='*';
    matrice[5][2]='@';
    matrice[5][3]='@';
    matrice[5][4]='@';
    matrice[5][5]='@';
    matrice[5][6]='@';
    matrice[5][7]='@';
    matrice[6][0]='@';
    matrice[6][1]='@';
    matrice[6][2]='@';
    matrice[6][3]='@';
    matrice[6][4]='@';
    matrice[6][5]='@';
    matrice[6][6]='@';
    matrice[6][7]='@';
    matrice[7][0]='@';
    matrice[7][1]='*';
    matrice[7][2]='@';
    matrice[7][3]='@';
    matrice[7][4]='@';
    matrice[7][5]='@';
    matrice[7][6]='@';
    matrice[7][7]='@';
     
    }
     
    void affichage(char **matrice, int n)
    {
    int j;
    	for (int i=0;i<n;i++)
    	{
    		printf("\n");
     
    		for (j=0;j<n;j++) printf("%c \t", matrice[i][j]);
    printf("--------------------------------------------------------------------------------\n");
        }
     
    }
     
     
    void affichier_rang(int r[],int n)
    {
         int i;
     
         printf("\n done \n");
    for (i=0;i<n;i++) 
    printf("rang du colonne %d =%d \t",i+1, r[i]);
    printf("\n \t");
     
     
    }
     
     
    void saisie ( char **m , int n)
    {
     
    char c;
     
    	for (int i=0;i<n;i++){
     
    		for (int j=0;j<n;j++)
    		{
     
    			printf("\ndonner un nouveau element , 2 espace pour laisser vide");
     
    			do{
     
     
    				c = getchar ();
    				if (c != '*' && c  != '@')
    				printf("\n ligne %d colonne %d", i+1, j+1);
     
    			}while (c != '*' && c  != '@');
     
     
     
     
    			m[i][j]=c;
     
     
    	}	}
     
     
    }
     
     
    //----------------- end of .H file
     
     
    int main()
    {
     
    char **m, **mat; int n;
    int *rang,*tab_date;
    int i;
     
    int rangMaxi; // Je déclare un entier
    //int *p_rangMaxi = &rangMaxi; // Je crée un pointeur sur cet enti
     
    printf("\n Donner la taille de la matrice ( donner 7 pour le test )  :");
     
    scanf("%d", &n);
     
    m= new char*[n] ;  
     
    mat=new char*[n];
     
    rang=new int[n];
    tab_date= new int [n];
       for (i=0; i<n;i++)   m[i]=new char[n];
     
     
     
     /*  for (i=0;i<n;i++)
       { printf("\n donner la dure du tache %d =", i);
         scanf("%d", &tab_date[i]);
         }*/
     
    //saisie(m,n);
    auto_saisie(m);
     
    affichage(m,n);
     
     
    RemplirPlusTOT(m,n,rang,&rangMaxi);
    reverse_matrice(m,n,mat);
     
    printf("\n ---- après classement -----------\n");
     
    affichier_rang(rang,n);
    affichage(mat,n);
     
    system("pause");
     
     
    return 0;  
    }

  5. #5
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par scofild20 Voir le message
    voici le code complet pour le test avec devc++

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    mat=new char*[n];
     
    rang=new int[n];
    tab_date= new int [n];
       for (i=0; i<n;i++)   m[i]=new char[n];
    Pas du C. Le C++, c'est à coté.

  6. #6
    Membre du Club Avatar de scofild20
    Inscrit en
    Mars 2007
    Messages
    109
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 109
    Points : 47
    Points
    47
    Par défaut
    oui mais le prof a volue une déclaration dynamique , et c'est pas ça qui a causé la problème

  7. #7
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par scofild20 Voir le message
    oui mais le prof a volue une déclaration dynamique , et c'est pas ça qui a causé la problème
    Si ton prof ne sait pas faire la différence entre le C et le C++, change de prof.

    L'allocation dynamique en C se fait avec malloc()/free().

Discussions similaires

  1. Petit problème de programmation.
    Par willow.A dans le forum C
    Réponses: 3
    Dernier message: 08/01/2007, 16h36
  2. Problème en programmant un GUI swing
    Par kaelem dans le forum AWT/Swing
    Réponses: 4
    Dernier message: 05/01/2007, 11h59
  3. Problème de programmation orientée objet
    Par dan65 dans le forum WinDev
    Réponses: 8
    Dernier message: 17/09/2006, 01h04
  4. problème finalisation programme
    Par depelek dans le forum Installation, Déploiement et Sécurité
    Réponses: 9
    Dernier message: 02/05/2006, 16h17
  5. Réponses: 1
    Dernier message: 26/09/2005, 19h29

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