分页: 1 / 1

Please keep this page until 2009.1.10 , thank u

发表于 : 2009-01-08 23:56
raptorsun
Procedure Exercise

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>

void int_tab(int,float[]);
void stat(int , float [], float &, float &);



main()
{
float tab[10000];//array up to 9999
int n = 0;
float m , e ;


n = 10000;

int_tab(n,tab);

stat(n,tab,m,e);

printf("Mean: %f\n Ecart: %f\n",m,e);

}

void stat(int n , float tab[], float &m, float &e)
{
int i; //loop var

//mean
m = 0;
for (i=0;i <= n-1 ; i = i+ 1)
{
m = m + tab;
}
m = m /n;

//ecart
e = 0;
for (i=0; i <= n-1; i = i+1)
{
e = e + tab*tab;
}
e = e/n - m*m;

e = sqrt(e);

return;
}



void int_tab(int n, float t[])
{
long j;
int i ;
//give random number to the array
time(&j);
srand48(j);

for(i = 0; i <= n-1;i=i+1)
{
t= drand48();
}

}

Re: Please keep this page until 2009.1.10 , thank u

发表于 : 2009-01-18 21:42
lerosua
顶到18号