各位幫忙看一下??!
#include <stdio.h>
int i,j;
int sortscore(int socre[])
{
? ? int temp;
? ? for(i=0;i<10;i++)
? ? {
? ? ? ? for(j=i+1;j<10;j++)
? ? ? ? {
? ? ? ? ? ? if(score[i]<score[j])
? ? ? ? ? ? ? ?temp=score[i];
? ? ? ? ? ? ? ?score[i]=score[j];
? ? ? ? ? ? ? ?socre[j]=temp;
? ? ? ? }
? ? ? ? return socre;
? ? }
}
int sumscore(int score[])
{
? ? for(i=;i<10;i++)
? ? {
? ? ? ? sum+=score[i];
? ? }
? ? return sum;
? ? printf("考試成績總分為:%d\n",sum);
}
int maxscore(int score[]){
? ? printf("最高分為:%d\n",score[N-1]);
}
int minscore(int score[]){
? ? printf("最低分為:%d\n",score[0]);
}
int avagerscore(int score[]){
? ? int avager;
? ? avager=sum/N;
? ? printf("平均分為:%d\n",avager);
}
int main()
{
? ? int score[10]={67,98,75,63,82,79,81,91,66,84};
? ? sortscore(score);
? ? sumscore(score);
? ? maxscore(score);
? ? minscore(score);
? ? avagerscore(score);
? ? printf("考試成績降序排序?yàn)?d\n",score[]);
? ? return 0;
}
hello.c:?In?function?'sortscore': hello.c:10:16:?error:?'score'?undeclared?(first?use?in?this?function) ?????????????if(score[i]
2018-07-17
有個地方?jīng)]寫上,
而且,你的排序是從大到小,最大值和最小值出錯了