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 :

créer un tableau à partir d'une table de hachage


Sujet :

C

  1. #61
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    En clair: Tu te fais une fonction qui prend en paramètre le tableau de structures TableauMotsCompacts et une chaîne, qui appelle la fonction de hachage dessus pour avoir un index et qui se sert de cet index pour appeler RechercherMot sur le bon tableau...
    Donc, on doit modifier la fonction r RechercherMot de telle sorte elle prend en entree l'index, non?

  2. #62
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Non, vu qu'on lui passe directement le tableau correspondant. Comme pour la fonction de tri.

  3. #63
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    Non, vu qu'on lui passe directement le tableau correspondant. Comme pour la fonction de tri.
    Ah oui c'est vrai des fonction callback,

  4. #64
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Non, les seules fonctions callback, ce sont celles avec "callback" dans le nom.

  5. #65
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Bonjour,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    void RechercherMotTableau(tableauMotsCompact *TMC, char* ch)
    {
      unsigned int const idx = HachageCompletMot(ch);
      return RechercherMotC(ch, n, TMC[idx])
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    unsigned int HachageCompletMots(char const *mots)
    {
    	return hash_chaine(mots);
    }
    c'est comme ça?

  6. #66
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Plus ou moins:
    Code C : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    MotCompact* RechercherMotCompact(TableauMotsCompacts *TMC, char const* ch)
    {
    	unsigned int const idx = HachageCompletMot(ch);
    	return RechercherMot(TMC[idx].pMotsCompacts, TMC[idx].nbMotsCompact, ch);
    }
    MotCompact const* RechercherMotCompactC(TableauMotsCompacts const* TMC, char const* ch)
    {
    	unsigned int const idx = HachageCompletMot(ch);
    	return RechercherMotC(TMC[idx].pMotsCompacts, TMC[idx].nbMotsCompact, ch);
    }
    PS: Décidément, tu l'aimes bien, ton "n"... Un jour il faudra m'expliquer d'où tu le sors...

  7. #67
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    PS: Décidément, tu l'aimes bien, ton "n"... Un jour il faudra m'expliquer d'où tu le sors...
    Bonjour Médinoc, tu vas bien ?
    en fait n c'est le nombre de MotCompact dans le tableau n'est ce pas?

  8. #68
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    j'ai encore une erreur de segmentation
    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
    void GenererLesRegles2fr1en(FILE*pfOut,  MotCompact const *pcLeft, MotCompact const *pcRight,MotCompact const pcMots3[],size_t n)
    {
        int sortie=0;
        double imc=0;
        size_t iLigneLeft = 0;
    	size_t iLigneRight = 0;
    	int const * pcCoordLeft  = ligne_GetPremierC(pcLeft, &iLigneLeft);
    	int const * pcCoordRight = ligne_GetPremierC(pcRight, &iLigneRight);
    	while(pcCoordLeft!=NULL && (!sortie) && pcCoordRight!=NULL)
    	{
    		{
    			int ligneRight = *pcCoordRight;
    			while(pcCoordLeft!=NULL && (*pcCoordLeft)>ligneRight)
    			pcCoordLeft = ligne_GetNextC(pcLeft, &iLigneLeft);
    		}
    		        if(pcCoordLeft==NULL)
    			break;
    		{
    			int ligneLeft = *pcCoordLeft;
    			while(pcCoordRight!=NULL && (!sortie)&& ligneLeft<(*pcCoordRight))
    			pcCoordRight = ligne_GetNextC(pcRight, &iLigneRight);
    		}
    		if(pcCoordRight==NULL)
    			break;
     
    		if(*pcCoordLeft == *pcCoordRight)
    		{
    		    char    const*Left=GetMotCompact(pcLeft);
    		    char    const*Right=GetMotCompact(pcRight);
    		    fprintf(pfOut,"%s",GetMotCompact(pcLeft));
    		   fprintf(pfOut,"->");
    		    fprintf(pfOut,"%s\n",GetMotCompact(pcRight));
                       imc=info_mut_cond(pcLeft,pcRight,pcMots3,n);
                      fprintf(pfOut,"IMC   =   ");
    		sortie=1;
    		    pcCoordLeft = ligne_GetNextC(pcLeft, &iLigneLeft);
    			pcCoordRight = ligne_GetNextC(pcRight, &iLigneRight);
    		}
     
    }
    }
    je vois pas pourquoi?
    une idée?
    Merci

  9. #69
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Bizarre cette erreur, là il affiche bien les 3 regles, mais à la fin il affiche cette erreur de segmentation

  10. #70
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Pas d'idée, mais commence déjà par indenter correctement...
    Code C : 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
    void GenererLesRegles2fr1en(FILE*pfOut, MotCompact const *pcLeft, MotCompact const *pcRight, MotCompact const pcMots3[], size_t n)
    {
    	int sortie=0;
    	double imc=0;
    	size_t iLigneLeft = 0;
    	size_t iLigneRight = 0;
    	int const * pcCoordLeft  = ligne_GetPremierC(pcLeft, &iLigneLeft);
    	int const * pcCoordRight = ligne_GetPremierC(pcRight, &iLigneRight);
    	while(pcCoordLeft!=NULL && (!sortie) && pcCoordRight!=NULL)
    	{
    		{
    			int ligneRight = *pcCoordRight;
    			while(pcCoordLeft!=NULL && (*pcCoordLeft)>ligneRight)
    				pcCoordLeft = ligne_GetNextC(pcLeft, &iLigneLeft);
    		}
    		if(pcCoordLeft==NULL)
    			break;
    		{
    			int ligneLeft = *pcCoordLeft;
    			while(pcCoordRight!=NULL && (!sortie)&& ligneLeft<(*pcCoordRight))
    				pcCoordRight = ligne_GetNextC(pcRight, &iLigneRight);
    		}
    		if(pcCoordRight==NULL)
    			break;
     
    		if(*pcCoordLeft == *pcCoordRight)
    		{
    			char    const*Left=GetMotCompact(pcLeft);
    			char    const*Right=GetMotCompact(pcRight);
    			fprintf(pfOut,"%s",GetMotCompact(pcLeft));
    			fprintf(pfOut,"->");
    			fprintf(pfOut,"%s\n",GetMotCompact(pcRight));
    			imc=info_mut_cond(pcLeft,pcRight,pcMots3,n);
    			fprintf(pfOut,"IMC   =   ");
    			sortie=1;
    			pcCoordLeft = ligne_GetNextC(pcLeft, &iLigneLeft);
    			pcCoordRight = ligne_GetNextC(pcRight, &iLigneRight);
    		}
    	}
    }

  11. #71
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Oui,
    à la fin il s'arrete à ce niveau
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    	while(pcCoordLeft!=NULL && (*pcCoordLeft)>ligneRight)
    apres avoir traité tous les séquences

  12. #72
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Je vois pas pourquoi cette erreur! elle me bloque vraiement là.
    On a fait comme ca avec les regles 1mot1mot, et ca marchait nikel
    Bizarre :s

  13. #73
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Sans le code qui utilise pcMots3, pas évident de t'aider.
    Surtout que là encore, je ne sais pas ce qu'est supposé signifier n...

  14. #74
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    le n pour dire TMC[idx].nbMotsCompact

  15. #75
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Sauf qu'à ma connaissance, quand tu appelles cette fonction, tu n'es pas encore supposée avoir un idx...

  16. #76
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    Sans le code qui utilise pcMots3, pas évident de t'aider.
    Surtout que là encore, je ne sais pas ce qu'est supposé signifier n...
    MotCompact const* RechercherMotC(MotCompact const pcMotsCompacts[], size_t nbMotsCompacts, char const * mot)
    mon n dans le code c'est nbMotsCompacts
    non?

  17. #77
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Mais tu n'es plus supposée appeler RechercherMotC() directement, depuis qu'on a écrit les fonctions RechercherMotCompact() et RechercherMotCompactC().
    Cela me semblait évident...

  18. #78
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    le probleme persiste encore ..
    ici
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    	while(pcCoordLeft!=NULL && (*pcCoordLeft)>ligneRight)
    Concernant MotCompact const pcMots3[], je l'utilise pour rechercher le mot EN dedans

  19. #79
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 379
    Points : 41 573
    Points
    41 573
    Par défaut
    Poste le code complet de GenererLesRegles2fr1en() et info_mut_cond().
    Et encore, je ne suis pas sûr de pouvoir t'aider même avec ça...

  20. #80
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Ok, merci
    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
    void GenererLesRegles2fr1en(FILE*pfOut, MotCompact const *pcLeft, MotCompact const *pcRight, MotCompact const pcMots3[])
    {
    	int sortie=0;
    	double imc=0;
    	size_t iLigneLeft = 0;
    	size_t iLigneRight = 0;
    	int const * pcCoordLeft  = ligne_GetPremierC(pcLeft, &iLigneLeft);
    	int const * pcCoordRight = ligne_GetPremierC(pcRight, &iLigneRight);
    	while(pcCoordLeft!=NULL && (!sortie) && pcCoordRight!=NULL)
    	{
    		{
    			int ligneRight = *pcCoordRight;
    			while(pcCoordLeft!=NULL && (*pcCoordLeft)>ligneRight)
    			pcCoordLeft = ligne_GetNextC(pcLeft, &iLigneLeft);
    		}
    		if(pcCoordLeft==NULL)
    			break;
    		{
    			int ligneLeft = *pcCoordLeft;
    			while(pcCoordRight!=NULL && (!sortie)&& ligneLeft<(*pcCoordRight))
    			pcCoordRight = ligne_GetNextC(pcRight, &iLigneRight);
    		}
    		if(pcCoordRight==NULL)
    			break;
     
    		if(*pcCoordLeft == *pcCoordRight)
    		{
    		    printf("%s",GetMotCompact(pcLeft));
    		   printf("->");
    		    printf("%s\n",GetMotCompact(pcRight));
                        imc=info_mut_cond(pcLeft,pcRight,pcMots3);
                        printf("IM   =   ");
                        printf("%e  \n",imc);
                        sortie=1;
    		    pcCoordLeft = ligne_GetNextC(pcLeft, &iLigneLeft);
    		   pcCoordRight = ligne_GetNextC(pcRight, &iLigneRight);
                  }
    }
    }
    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
    double info_mut_cond(MotCompact const *pc, MotCompact const *pc2,MotCompact const  pcMot[])
    {
    	double IM=0;
    	char const * mot = GetMotCompact(pc);
    	char * mot1 = malloc(sizeof (*mot1) * 256);
    	char * mot2 = malloc(sizeof (*mot2) * 256);
    	double  p1,p2,p3,p4,p5;
    	MotCompact const *m1;
        	MotCompact const *m2;
     
     
    	sscanf(mot, "%s %s", mot1, mot2);
     
    	m1= RechercherMotCompactC( pcMot,mot1);
       	 m2= RechercherMotCompactC(pcMot,mot2);
       	 p1=(NbLignesCommunes(pc,pc2)/((double)596831));
     
    	IM=p1;
    	return  IM;
    }
    Mais je pense pas que le souci vient de la 2eme fonction, car quand je la supprime, l'erreur persiste encore :s

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

Discussions similaires

  1. [MySQL] Créer un tableau à partir d'une base de données
    Par barakobama95 dans le forum PHP & Base de données
    Réponses: 15
    Dernier message: 30/09/2013, 16h58
  2. Créer un array à partir d'une table
    Par FanFan44 dans le forum Débutez
    Réponses: 4
    Dernier message: 14/06/2013, 17h50
  3. [MySQL] Créer un tableau à partir d'une requete SQL
    Par extream dans le forum PHP & Base de données
    Réponses: 14
    Dernier message: 02/06/2013, 20h11
  4. Réponses: 1
    Dernier message: 17/04/2013, 20h00
  5. [MySQL] créer un tableau à partir d'une base de donnée
    Par bastien dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 21/01/2009, 15h03

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