24 lines
577 B
C
24 lines
577 B
C
|
#include "power.h"
|
||
|
#include "getArray.h"
|
||
|
|
||
|
double power(int tab[nRow][8]){
|
||
|
double periode = 1 /freqEch;
|
||
|
double power[8];
|
||
|
for(int i = 0; i < 8; i++){
|
||
|
int j = 0;
|
||
|
double res = 0;
|
||
|
while(1){
|
||
|
if(!tab[j+1][i]) break;
|
||
|
double aire = ( pow(tab[j][i],2) + pow(tab[j+1][i],2) ) / 2 * periode;
|
||
|
res += aire;
|
||
|
j++;
|
||
|
}
|
||
|
power[i] = res;
|
||
|
}
|
||
|
return *power;
|
||
|
}
|
||
|
int main(int argc , char** argv){
|
||
|
FILE *f = fopen(argv[1],"r");
|
||
|
double pw = power(getArray(nRow,f));
|
||
|
printf("%d" , pw);
|
||
|
}
|