Skip to content

Commit

Permalink
Add preliminary mean() with lousy generics :(
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanYoung committed Sep 23, 2014
1 parent 6cfeb5c commit 15b1da6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ int numcmp (const void *a, const void *b) {
return 0;
}

int mean(const void *a, int length, int size){
int sum = 0;
switch(size){
case sizeof(int):
for (int i = 0; i < length; i++)
sum += *((int*) a)
break;
case sizeof(double):
for (int i = 0; i < length; i++)
sum += *((double*) a)
break;

result = (double) sum/length
}

int main(int argc, char *argv[]) {

int i, length, *pt;
Expand Down

0 comments on commit 15b1da6

Please sign in to comment.