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 :

Conflit de type


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 264
    Par défaut Conflit de type
    bonsoir, voila sa fait depuis un petit moment que j'essaye de compiler mon programme.

    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
    #include<math.h>
    #include<stdio.h>
    #include<stdlib.h>
    # define NB 4
     
     
     
     
    main()
    {
          float SerieX[NB] ;
          float SerieY[NB] ; 
          int i, j , n; 
          float Xm, Ym ; /* récup les moyennes */
     
          printf("Bonjour, vous allez entrer dans un programme qui trouve s'il ya un rapport entre les val X et Y \n");
     
     
          for(i=0; i< NB; i++)
          {
                    printf("entrer la val num %d \n",i);
                    scanf("%f", &SerieX[i]) ;               
          }
     
          for(j=0; j< NB; j++)
          {
                    printf("entrer la val num %d \n",j);
                    scanf("%f", &SerieY[j]) ;               
          }
     
        printf("-------------------------------------------------\n");  
     
     
    /* Calcul de la moyen des série */
       Xm = moyen( &SerieX ) ; 
       Ym = moyen( &SerieY) ; 
    /*    
       moyen( &SerieX) ; 
       moyen( &SerieY) ; 
       */
       printf("la moyen de la 1er serie est de %d \n", Xm); 
       printf("la moyen de la 2emme serie est de %d \n", Ym); 
     
     
     system("PAUSE");      
    }
     
    float moyen  ( float tab[] )
    {
          float som = 0 ;
          float res = 0;
          int i ;
     
          for ( i = 0 ; i<NB; i++)
          {
             som = som + tab[i];      
          }
     
          res = som / i ;
     
        return res ; 
    }
     
    float equarT( float a)
    {
          float res ; 
     
          res = sqrt(a) ;
     
          return res ;
     
     
    }
     
    int var ( float * tab )
    {
        float som = 0 ;
        float res ;
        int i ;
        for(i =0 ; i <NB ; i++)
        {
              som = som + ( tab[i] - moyen(&tab) ) ;
        }                
     
        res = (1 /NB) * ( som) ;     
     
        return res ; 
     
    }
     
    float covar( float * tab1 , float * tab2 )
    {
          float som = 0 ;
          float res ;
          int i ;
     
          for( i =0 ; i<NB ; i++ )
          {
               som = som +(  ( tab1[i] - moyen(&tab1)) * ( tab2[i] - moyen(&tab2) )  ) ;
          }
          res = (1 /NB) * ( som) ;     
     
          return res ; 
    }
     
    void app ( float *tab1, float *tab2, float x , float y  )
    {
          float resu ;
     
          resu = covar( & tab1 , & tab2)  / ( equarT(x) * equarT(y) ) ;
     
          if( resu <= 1)
              printf("c'est lineaire, donc resultat theorique \n");
     
          else if ( (resu <1)  && (resu > 0,8)) 
              printf("L'alignement lieaire se justifie, ou on parle de regression affine \n");
     
          else if( (resu >1) && (resu < 0,8 )) 
               printf(" n'a pas de sens \n") ; 
    }
    conflicting types for 'moyen' 35
    previous implicit declaration of 'moyen' was here

    je ne comprends pas le probléme, j'ai tourné dans tous les sens sans résultats ?

  2. #2
    Membre Expert Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Par défaut
    tu es sûr qu'il n'y a que ça?
    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
    test2.c:10: attention : return type defaults to «int"
    test2.c:10: attention : function declaration isn"t a prototype
    test2.c: In function «main":
    test2.c:35: erreur: implicit declaration of function «moyen"
    test2.c:35: attention : nested extern declaration of «moyen"
    test2.c:41: attention : format «%d" expects type «int", but argument 2 has type «double"
    test2.c:42: attention : format «%d" expects type «int", but argument 2 has type «double"
    test2.c:13: attention : unused variable «n"
    test2.c: Hors de toute fonction :
    test2.c:49: attention : no previous prototype for «moyen"
    test2.c:49: erreur: conflicting types for «moyen"
    test2.c:35: erreur: previous implicit declaration of «moyen" was here
    test2.c:65: attention : no previous prototype for «equarT"
    test2.c:76: attention : no previous prototype for «var"
    test2.c: In function «var":
    test2.c:82: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c: Hors de toute fonction :
    test2.c:92: attention : no previous prototype for «covar"
    test2.c: In function «covar":
    test2.c:99: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c:99: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c: Hors de toute fonction :
    test2.c:107: attention : no previous prototype for «app"
    test2.c: In function «app":
    test2.c:110: attention : passing argument 1 of «covar" from incompatible pointer type
    test2.c:110: attention : passing argument 2 of «covar" from incompatible pointer type
    test2.c:110: attention : passing argument 1 of «equarT" as «float" rather than «double" due to prototype
    test2.c:110: attention : passing argument 1 of «equarT" as «float" rather than «double" due to prototype
    test2.c:115: attention : l'opérande à gauche de la virgule n'a pas d'effet
    test2.c:118: attention : l'opérande à gauche de la virgule n'a pas d'effet

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 264
    Par défaut
    euu oui, j'ai corrigé maintenant en méttant un prototype de la fonction !

    et je n'ai plus que qq warning !

    je suis sous Dev c++

  4. #4
    Membre Expert Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Par défaut
    on peut voir la correction s'il te plaît?

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 264
    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
    #include<math.h>
    #include<stdio.h>
    #include<stdlib.h>
    #define NB 4
     
     
    float moyen ( float * ) ;
     
    main()
    {
          float SerieX[NB] ;
          float SerieY[NB] ; 
          int i, j , n; 
          float Xm, Ym ; /* récup les moyennes */
     
          printf("Bonjour, vous allez entrer dans un programme qui trouve s'il ya un rapport entre les val X et Y \n");
          printf(" NB = %d \n", NB);               
     
          for(i=0; i< NB; i++)
          {
                    printf("entrer la val num %d \n",i);
                    scanf("%f", &SerieX[i]) ;               
          }
          printf(" 2emme serie \n");
          for(j=0; j< NB; j++)
          {
                    printf("entrer la val num %d \n",j);
                    scanf("%f", &SerieY[j]) ;               
          }
     
        printf("-------------------------------------------------\n");  
     
        for(i = 0 ; i < 4 ; i ++ ) 
        {
              printf(" tab seriX = %d \n", SerieX[i] ) ;
              printf(" tab seriY = %d \n", SerieY[i] ) ;
              printf("***********\n") ;
        }
     
     
     
    /* Calcul de la moyen des série */
       Xm = moyen( &SerieX ) ; 
       Ym = moyen( &SerieY) ; 
    /*    
       moyen( &SerieX) ; 
       moyen( &SerieY) ; 
       */
       printf("la moyen de la 1er serie est de %d \n", Xm); 
       printf("la moyen de la 2emme serie est de %d \n", Ym); 
     
     
     system("PAUSE");      
    }
     
    float moyen  ( float  * tab )
    {
          float som = 0 ;
          float res = 0;
          int i ;
     
          for ( i = 0 ; i<NB; i++)
          {
             som = som + tab[i];
             printf("tab[%d] = %d \n", i, tab[i] ) ;      
          }
          printf("som = %d ,   NB = %d \n", som, NB ) ; 
          res = som / i ;
     
        return res ; 
    }
     
    float equarT( float a)
    {
          float res ; 
     
          res = sqrt(a) ;
     
          return res ;
     
     
    }
     
    int var ( float * tab )
    {
        float som = 0 ;
        float res ;
        int i ;
        for(i =0 ; i <NB ; i++)
        {
              som = som + ( tab[i] - moyen(&tab) ) ;
        }                
     
        res = (1 /NB) * ( som) ;     
     
        return res ; 
     
    }
     
    float covar( float * tab1 , float * tab2 )
    {
          float som = 0 ;
          float res ;
          int i ;
     
          for( i =0 ; i<NB ; i++ )
          {
               som = som +(  ( tab1[i] - moyen(&tab1)) * ( tab2[i] - moyen(&tab2) )  ) ;
          }
          res = (1 /NB) * ( som) ;     
     
          return res ; 
    }
     
    void app ( float *tab1, float *tab2, float x , float y  )
    {
          float resu ;
     
          resu = covar( & tab1 , & tab2)  / ( equarT(x) * equarT(y) ) ;
     
          if( resu <= 1)
              printf("c'est lineaire, donc resultat theorique \n");
     
          else if ( (resu <1)  && (resu > 0,8)) 
              printf("L'alignement lieaire se justifie, ou on parle de regression affine \n");
     
          else if( (resu >1) && (resu < 0,8 )) 
               printf(" n'a pas de sens \n") ; 
    }

  6. #6
    Membre Expert Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Par défaut
    tu as corrigé quelque chose là?
    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
    test2.c:10: attention : return type defaults to «int"
    test2.c:10: attention : function declaration isn"t a prototype
    test2.c: In function «main":
    test2.c:35: attention : format «%d" expects type «int", but argument 2 has type «double"
    test2.c:36: attention : format «%d" expects type «int", but argument 2 has type «double"
    test2.c:43: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c:44: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c:49: attention : format «%d" expects type «int", but argument 2 has type «double"
    test2.c:50: attention : format «%d" expects type «int", but argument 2 has type «double"
    test2.c:13: attention : unused variable «n"
    test2.c: In function «moyen":
    test2.c:65: attention : format «%d" expects type «int", but argument 3 has type «double"
    test2.c:67: attention : format «%d" expects type «int", but argument 2 has type «double"
    test2.c: Hors de toute fonction :
    test2.c:74: attention : no previous prototype for «equarT"
    test2.c:85: attention : no previous prototype for «var"
    test2.c: In function «var":
    test2.c:91: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c: Hors de toute fonction :
    test2.c:101: attention : no previous prototype for «covar"
    test2.c: In function «covar":
    test2.c:108: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c:108: attention : passing argument 1 of «moyen" from incompatible pointer type
    test2.c: Hors de toute fonction :
    test2.c:116: attention : no previous prototype for «app"
    test2.c: In function «app":
    test2.c:119: attention : passing argument 1 of «covar" from incompatible pointer type
    test2.c:119: attention : passing argument 2 of «covar" from incompatible pointer type
    test2.c:119: attention : passing argument 1 of «equarT" as «float" rather than «double" due to prototype
    test2.c:119: attention : passing argument 1 of «equarT" as «float" rather than «double" due to prototype
    test2.c:124: attention : l'opérande à gauche de la virgule n'a pas d'effet
    test2.c:127: attention : l'opérande à gauche de la virgule n'a pas d'effet
    test2.c:124: attention : ne sera jamais exécuté

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 264
    Par défaut
    oula , tu utilisa quoi pour avoir autant de message, ?

    Pourquoi c'est faux la déclaration ??

    j'ai précisé une variable float du type pointeur !

  8. #8
    Expert confirmé

    Inscrit en
    Août 2006
    Messages
    3 967
    Détails du profil
    Informations forums :
    Inscription : Août 2006
    Messages : 3 967
    Par défaut
    Giu,

    Regarde comment tu appelles ta fonction et comment tu la déclares.

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

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par bdptaki Voir le message
    bonsoir, voila sa fait depuis un petit moment que j'essaye de compiler mon programme.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <...>
    float moyen  ( float tab[] )
    {
    <...>
    }
    <...>
              som = som + ( tab[i] - moyen(&tab) ) ;
    <...>
               som = som +(  ( tab1[i] - moyen(&tab1)) * ( tab2[i] - moyen(&tab2)
    conflicting types for 'moyen' 35
    previous implicit declaration of 'moyen' was here
    Bah, oui, la fonction attend l'adresse d'un float, pas l'adresse d'un tableau de float... Retire le '&' dans l'appel...

  10. #10
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 264
    Par défaut
    SAlut ,alors mon probléme est résulo....

    Mon compilateur n'accépte pas la saisie de float , je ne comprends pas pourquoi mais bon ...
    je suis passé en double mais je n'ai plus de probléme

    Merci pour la version corrigée et toutes interventions

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

Discussions similaires

  1. Réponses: 4
    Dernier message: 12/11/2009, 17h09
  2. conflit de types
    Par Invité dans le forum Débuter
    Réponses: 4
    Dernier message: 04/09/2009, 10h43
  3. Réponses: 1
    Dernier message: 13/08/2009, 12h12
  4. [Moteur 2D de simulation] Conflit de type
    Par azertylr dans le forum SDL
    Réponses: 4
    Dernier message: 21/07/2007, 11h37
  5. Erreur de conflit de type
    Par Jhulk dans le forum C
    Réponses: 15
    Dernier message: 16/01/2006, 15h47

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