Pb avec fonctions sqrt de math.h

fox88 Messages postés 15 Date d'inscription jeudi 25 mars 2004 Statut Membre Dernière intervention 9 juillet 2004 - 25 juin 2004 à 15:49
fox88 Messages postés 15 Date d'inscription jeudi 25 mars 2004 Statut Membre Dernière intervention 9 juillet 2004 - 25 juin 2004 à 16:32
voici mon code :

void histod::calcul_moyenne_ecartype()
{
  //CALCUL MOYENNE DU NB D'APPELS MOYEN JOURNALIER
  unsigned long accu=0;
  int moyenne=0;
  int tmp=0;
  int compteur=0;
  for(int i=0;i<nb_annees;i++) 
//get_bissex : renvoie bool indiquant si annee bissextile ou non
    for(int j=0;j<(tab[i]->get_bissex() ? 366 : 365);j++)
    {
     //somme_tab : renvoie la somme des elements du tab
      tmp=somme_tab((*tab[i])[j]->get_nbappels(),24);
      if(tmp>0) 
      {
        accu+=tmp;
        compteur++;
      }
    }
  for(int i=0;i<nb_annees_h;i++)
    for(int j=0;j<(tab_h[i]->get_bissex() ? 366 : 365);j++)
    {
      tmp=somme_tab((*tab_h[i])[j]->get_nbappels(),12);
      if(tmp>0) 
      {
        accu+=tmp;
        compteur++;
      }
    }
  moyenne=accu/compteur; 
  
  //CALCUL DE L'ECART TYPE
  accu=0;
  compteur=0;
  int ecartype=0;
  for(int i=0;i<nb_annees;i++)
    for(int j=0;j<(tab[i]->get_bissex() ? 366 : 365);j++)
    {
      tmp=somme_tab((*tab[i])[j]->get_nbappels(),24);
      if(tmp>0) 
      {
        accu+=tmp*tmp;
        compteur++;
      }
    }
  for(int i=0;i<nb_annees_h;i++)
    for(int j=0;j<(tab_h[i]->get_bissex() ? 366 : 365);j++)
    {
      tmp=somme_tab((*tab_h[i])[j]->get_nbappels(),12);
      if(tmp>0) 
      {
        accu+=tmp*tmp;
        compteur++;
      }
    }
  ecartype=(accu/compteur-moyenne*moyenne);
  ecartype=sqrt(ecartype);
}


à la compilation avec DevCpp

call of overloaded `sqrt(int&)' is ambiguous


or ecartype st declaré comme un int ??????

1 réponse

fox88 Messages postés 15 Date d'inscription jeudi 25 mars 2004 Statut Membre Dernière intervention 9 juillet 2004
25 juin 2004 à 16:32
ben j'ai trouvé la solution au probleme .... il faut ecrire :

ecartype=(int)sqrt((double)ecartype);
0
Rejoignez-nous