#include <stdio.h>
void compute_mass(int num,float *mass,float *sum,float *ave) {
int i=0;
*sum = 0;
*ave = 0;
for(i=0;i<num;i++) {
*sum = *sum + mass[i];
}
if(num) {
*ave = *sum/((float) num);
}
}
int main(void) {
// your code goes here
int i;
float taiju[10]={58.6,65.2,74.4,46.0,52.8,62.4,55.0,51.2,54.8,48.4};
float total,average;
compute_mass(10,taiju,&total,&average);
printf("Average=%.1f\n",average
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGNvbXB1dGVfbWFzcyhpbnQgbnVtLGZsb2F0ICptYXNzLGZsb2F0ICpzdW0sZmxvYXQgKmF2ZSkgewoJaW50IGk9MDsKCSpzdW0gPSAwOwoJKmF2ZSA9IDA7Cglmb3IoaT0wO2k8bnVtO2krKykgewoJCSpzdW0gPSAqc3VtICsgbWFzc1tpXTsKCX0KCWlmKG51bSkgewoJKmF2ZSA9ICpzdW0vKChmbG9hdCkgbnVtKTsKCX0KfQoKaW50IG1haW4odm9pZCkgewoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJaW50IGk7CglmbG9hdCB0YWlqdVsxMF09ezU4LjYsNjUuMiw3NC40LDQ2LjAsNTIuOCw2Mi40LDU1LjAsNTEuMiw1NC44LDQ4LjR9OwoJZmxvYXQgdG90YWwsYXZlcmFnZTsKCWNvbXB1dGVfbWFzcygxMCx0YWlqdSwmdG90YWwsJmF2ZXJhZ2UpOwoJCglwcmludGYoIlRvdGFsPSUuMWZcbiIsdG90YWwpOwoJcHJpbnRmKCJBdmVyYWdlPSUuMWZcbiIsYXZlcmFnZSk7CglyZXR1cm4gMDsKfQo=