求平均工资(数组名做参数).c 260 B

1234567891011121314151617
  1. #include <stdio.h>
  2. int main() {
  3. int n, i;
  4. scanf("%d", &n);
  5. double salary[n], sum = 0.0;
  6. for(i = 0; i < n; i++) scanf("%lf", &salary[i]);
  7. for(i = 0; i < n; i++) sum += salary[i];
  8. double average = sum / n;
  9. printf("%.2lf", average);
  10. return 0;
  11. }