#include <stdio.h>
#define N 10
void tatalScore(int score[])
{
int i;
int sum=0;
for (i=0;i<N;i++)
{
sum+=score(i);
}
return sum;
}
void highScore(int score[])
{
int i=0;
int max;
max=score[i];
for (i=1;i<N;i++)
{
if (max<score[i])
{
max=score[i];
}
}
return max;
}
void lowScore(int score[])
{
int i=0;
int min;
min=score[i];
for (i=1;i<N;i++)
{
if (min>score[i])
{
min=score[i];
}
}
return min;
}
void averageScore(int score[])
{
int i,sum,ave;
sum=0;
for (i=0;i<N;i++)
{
sum+=score(i);
}
ave=sum/N;
return ave;
}
void getScore(int score[])
{
int i,j,max;
max=score(0)
for (i=0;i<N;i++)
{
for (j=0;j<N-i-1;j++)
{
if (score(j)<score(j+1))
{
max=score(j);
score(j)=score(j+1);
score(j+1)=max;
}
}
for(i=0;i<N;i++)
{
printf("%d ",score[i]);
}
printf("\n");
}
}
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
int sum,max,min,ave;
sum=tatalScore(score);
max=highScore(score);
min=lowScore(score);
ave=averageScore(score);
printf("学生考试的总分为%d\n。",sum);
printf("学生考试的最高分为%d\n。",max);
printf("学生考试的最低分为%d\n。",min);
printf("学生考试的平均分为%d\n。",ave);
printf("学生考试的降序排序为:\n");
getScore(score);
return 0;
}
宽容囖
别逼我打开屏幕
宽容囖
相关分类