#include <stdio.h> float f(int x)//实现遍历统计短信费用的函数 { int arr[x]; int i = 0; for (i = 0; i < x; i++) { scanf("%d ", &arr[i]); } float sum = 0; for (i = 0; i < x; i++) { float charge = 0.1; if (arr[i] > 60) { charge = 0.2; } sum += charge; } return sum; } int main() { int n = 0;//短信的条数 scanf("%d", &n); float result = 0; result = f(n);//调用函数 printf("%.1f\n", result); return 0; }