慕盖茨1169855
2020-08-22 15:47
#include <stdio.h>
#define N 11
int Sum(int score[])
{
int sum=0;
for(int i=0;i<10;i++)
sum+=score[i];
printf("sum=%d\n",sum);
return sum;
}
int Max(int score[])
{
int max=score[0];;
for(int i=1;i<10;i++)
{
if(max<=score[i])
{
max=score[i];
printf("max=%d\n",max);
}
}
return max;
}
int Min(int score[])
{
int min=score[0];;
for(int i=1;i<10;i++)
{
if(min>=score[i])
{
min=score[i];
printf("min=%d\n",min);
}
}
return min;
}
double Avg(int score[])
{
double avg=Sum(score)/10.0;
printf("avg=%f\n",avg);
return avg;
}
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
Sum(score);
Max(score);
Min(score);
Avg(score);
return 0;
}
#include <stdio.h> #define N 11 int Sum(int score[]) { int sum=0; for(int i=0;i<10;i++) sum+=score[i]; return sum; } int Max(int score[]) { int max=score[0];; for(int i=1;i<10;i++) { if(max<=score[i]) { max=score[i]; } } return max; } int Min(int score[]) { int min=score[0];; for(int i=1;i<10;i++) { if(min>=score[i]) { min=score[i]; } } return min; } double Avg(int score[]) { double avg=Sum(score)/10.0; return avg; } int main() { int score[N]={67,98,75,63,82,79,81,91,66,84}; printf("sum=%d\n",Sum(score)); printf("max=%d\n",Max(score)); printf("min=%d\n",Min(score)); printf("avg=%f\n",Avg(score)); return 0; }
C语言入门
926210 学习 · 20797 问题
相似问题