fox88
Messages postés15Date d'inscriptionjeudi 25 mars 2004StatutMembreDernière intervention 9 juillet 2004
-
25 juin 2004 à 15:49
fox88
Messages postés15Date d'inscriptionjeudi 25 mars 2004StatutMembreDerniè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);
}