Created
October 6, 2010 02:19
-
-
Save kaldas/612703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //by rcaldasmd | |
| #include <stdio.h> | |
| #include <math.h> | |
| int main() | |
| { | |
| int cnt = 0, //contador de uso geral | |
| bsz = 0, //numero de elementos no array buff excluindo o null byte | |
| adt = 0; //resultado da soma dos elementos | |
| double mean = 0, //media dos elementos | |
| dsvp = 0, //raiz quadrada da variação | |
| aqr = 0; //resultado da soma dos elemtentos ao quadrado | |
| int buff[] = {10,10,5,5}; | |
| bsz = sizeof(buff) / sizeof(int); | |
| for(cnt=0;cnt != bsz;cnt++) | |
| adt += buff[cnt]; | |
| mean = adt / bsz; | |
| for(cnt=0;cnt != bsz;cnt++) | |
| aqr = aqr + (buff[cnt] * buff[cnt]); | |
| aqr = aqr / (bsz - 1); | |
| dsvp = sqrt(aqr); | |
| printf("\n Mean: %2.2f | Standard Deviation: %3.3lf\n",mean,dsvp); | |
| printf(" Variance: %f | Total Elements: %i | Total addt: %i\n\n",aqr,bsz,adt); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment