经典的学生成绩统计算法
#include <stdio.h>
double find(int total, int n) {
int number, score, average;
scanf("%d", &number);
if(number != 0) {
scanf("%d", &score);
average = find(total+score, n+1);
if(score >= average)
printf("%d:%d\n", number, score);
return average;
} else {
printf("Average=%d\n", total/n);
return total/n;
}
}
int main(int argc, char* argv[]) {
find(0, 0);
}
double find(int total, int n) {
int number, score, average;
scanf("%d", &number);
if(number != 0) {
scanf("%d", &score);
average = find(total+score, n+1);
if(score >= average)
printf("%d:%d\n", number, score);
return average;
} else {
printf("Average=%d\n", total/n);
return total/n;
}
}
int main(int argc, char* argv[]) {
find(0, 0);
}