#include <stdio.h>
int main()
{
int score[]={67,98,75,63,82,79,81,91,66,84};
int num;
int all;
int i;
int j;
int qw;
for(num=0,all=0;num<10;num++)
{
all+=score[num];
}
printf("这次考试十个学生的总分是%d。\n",all);
printf("这次考试的平均分是%.1f。\n",all/10.0);
for(qw=0;qw<=10;qw++)
{
for(j=0;j<=9;)
{
if(score[j]<score[j+1])
{
i=score[j+1];
score[j+1]=score[j];
score[j]=i;
}
j+=1;
}
}
printf("这次考试最高分是%d。\n",score[0]);
printf("这次考试最低分是%d。\n",score[9]);
printf("这次考试按排名排是 ");
for(i=0;i<=9;i++)
{
printf("第%d名:%d分。",i+1,score[i]);
}
return 0;
}
#include <stdio.h> #define N 10 void number(int score[]) { int i; printf("\n"); for(i=0;i<N;i++) { printf("%d",score[i]); } printf("\n"); } int sum(int score[]) { int i,sum=0; for(i=0;i<N;i++) { sum+=score[i]; } return sum; } int maxscore(int score[]) { int i,max=-1; for(i=1;i<N;i++) { if(max<score[i]) max=score[i]; } return max; } int minscore(int score[]) { int i; int min=100; for(i=1;i<N;i++) { if(min>score[i]) min=score[i]; } return min; } int average(int score[],int n) { return sum(score)/N; } void sort(int score[]) { int i,j,temp; for(i=N-2;i>=0;i--) { for(j=0;j<=i;j++) { if(score[j]<score[j+1]) { temp=score[j]; score[j]=score[j+1]; score[j+1]=temp; } } } number(score); } int main() { int score[N]={67,98,75,63,82,79,81,91,66,84}; printf("最高分为%d\n",maxscore(score)); printf("最低分为%d\n",minscore(score)); printf("总分为%d\n",sum(score)); printf("平均分为%d\n",average(score,N)); sort(score); return 0; }