题解 | #牛牛的短信#
牛牛的短信
http://www.nowcoder.com/practice/435c9e2bf4f84bee99b82ce84e95b0b7
#include <stdio.h>
float fun(int *a,int n){
float sum=0;
while(n--){
if(*a>60) sum+=0.2;
else sum+=0.1;
a++;
}
return sum;
}
int main(){
int n,a[100];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("%.2f",fun(a,n));
}
float fun(int *a,int n){
float sum=0;
while(n--){
if(*a>60) sum+=0.2;
else sum+=0.1;
a++;
}
return sum;
}
int main(){
int n,a[100];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("%.2f",fun(a,n));
}