哪位大佬幫忙看看哪里錯(cuò)了
#include <stdio.h>
#define N 10
int totalscore(int score[])
{
? ? for(int i=0;i<10;i++)
? ? {
? ? ? ? int total=0;
? ? ? ? total=total+score[i];
? ? }
? ? return total;
}
int maxscore(int score[])
{
? ? int max=score[0];
? ? for(int i=0;i<9;i++)
? ? {
? ? ? ? if(score[i]>max)
? ? ? ? {
? ? ? ? ? ? max=score[i];
? ? ? ? }
? ? }
? ? return max;
}
int minscore(int score[])
{
? ? int min=score[0];
? ? for(int i=0;i<9;i++)
? ? {
? ? ? ? if(score[i]<min)
? ? ? ? {
? ? ? ? ? ? min=score[i];
? ? ? ? }
? ? }
? ? return min;
}
int averagescore(int score[])
{
? ? int average;
? ? average=(totalscore(score))/10;
? ? return average;
}
void orderscore(int score[],N)
{
? ? for(int i=N-1;i>=0;i--)
? ? {
? ? ? ? for(int j=0;j<=i;j++)
? ? ? ? {
? ? ? ? ? ? if(score[j]<score[j+1])
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int temp=score[j];
? ? ? ? ? ? ? ? score[j]=score[j+1];
? ? ? ? ? ? ? ? score[j+1]=score[j];
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? for(int i=0;i<10;i++)
? ? {
? ? printf("成績降序排列為:",score[i]);
? ? ? ??
? ? }
}
int main()
{
? ??
? ? int score[N]={67,98,75,63,82,79,81,91,66,84};
? ? int Total=totalscore(score);
? ? int Max=maxscore(score);
? ? int Min=minscore(score);
? ? int Average=averagescore(score);
? ??
? ? printf("總分為:%d",Total);
? ? printf("最高分為:%d",Max);
? ? printf("最低分為:%d",Min);
? ? printf("平均分為:%d",Average);
? ? order(score);
? ? return 0;
}
2021-08-29
#include <stdio.h>
#define N 10
int totalscore(int score[])
{
? ? int total=0;//第1處修改
? ? for(int i=0;i<10;i++)
? ? {
? ? ? ? //int total=0;此處錯(cuò)誤1
? ? ? ? total=total+score[i];
? ? }
? ? return total;
}
int maxscore(int score[])
{
? ? int max=score[0];
? ? for(int i=1;i<N;i++)//此處錯(cuò)誤2
? ? {
? ? ? ? if(score[i]>max)
? ? ? ? {
? ? ? ? ? ? max=score[i];
? ? ? ? }
? ? }
? ? return max;
}
int minscore(int score[])
{
? ? int min=score[0];
? ? for(int i=1;i<N;i++)//此處錯(cuò)誤3
? ? {
? ? ? ? if(score[i]<min)
? ? ? ? {
? ? ? ? ? ? min=score[i];
? ? ? ? }
? ? }
? ? return min;
}
double averagescore(int score[])
{
? ? double average;//此處錯(cuò)誤4,平均數(shù)最好用浮點(diǎn)數(shù)表示。
? ? average=(totalscore(score))/10.0;
? ? return average;
}
void orderscore(int score[],N)
{
? ? for(int i=N-1;i>=0;i--)
? ? {
? ? ? ? for(int j=1;j<=i;j++)//此處錯(cuò)誤5
? ? ? ? {
? ? ? ? ? ? if(score[j-1]<score[j])//此處錯(cuò)誤6
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int temp;//此處錯(cuò)誤8
? ? ? ? ? ? ? ? temp=score[j-1];
? ? ? ? ? ? ? ? score[j-1]=score[j];
? ? ? ? ? ? ? ? score[j]=temp;
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? for(int i=0;i<10;i++)
? ? {
? ? printf("成績降序排列為:",score[i]);
? ? ? ??
? ? }
}
int main()
{
? ??
? ? int score[N]={67,98,75,63,82,79,81,91,66,84};
? ? int Total=totalscore(score);
? ? int Max=maxscore(score);
? ? int Min=minscore(score);
? ? double Average=averagescore(score);
? ??
? ? printf("總分為:%d",Total);
? ? printf("最高分為:%d",Max);
? ? printf("最低分為:%d",Min);
? ? printf("平均分為:%lf",Average);
? ? order(score);
? ? return 0;
}
2021-08-03
#include <stdio.h>
int totalscore(int score[])
{
? ? int total=0;
? ? for(int i=0;i<10;i++)
? ? {
? ? ? ? total=total+score[i];
? ? }
? ? return total;
}
int maxscore(int score[])
{
? ? int max=score[0];
? ? for(int i=0;i<10;i++)
? ? {
? ? ? ? if(score[i]>max)
? ? ? ? {
? ? ? ? ? ? max=score[i];
? ? ? ? }
? ? }
? ? return max;
}
int minscore(int score[])
{
? ? int min=score[0];
? ? for(int i=0;i<10;i++)
? ? {
? ? ? ? if(score[i]<min)
? ? ? ? {
? ? ? ? ? ? min=score[i];
? ? ? ? }
? ? }
? ? return min;
}
float averagescore(int score[])
{
? ? int average;
? ? average=(totalscore(score))/10;
? ? return average;
}
void orderscore(int score[])
{
? ? for(int i=9;i>=0;i--)
? ? {
? ? ? ? for(int j=0;j<=i;j++)
? ? ? ? {
? ? ? ? ? ? if(score[j]<score[j+1])
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int temp=score[j];
? ? ? ? ? ? ? ? score[j]=score[j+1];
? ? ? ? ? ? ? ? score[j+1]=temp;
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? printf("成績降序排列為:");
? ? for(int i=0;i<10;i++)
? ? {
? ??
? ? printf("%d ",score[i]);
? ? ? ??
? ? }
}
int main()
{
? ??
? ? int score[10]={67,98,75,63,82,79,81,91,66,84};
? ? int Total=totalscore(score);
? ? int Max=maxscore(score);
? ? int Min=minscore(score);
? ? int Average=averagescore(score);
? ??
? ? printf("總分為:%d\n",Total);
? ? printf("最高分為:%d\n",Max);
? ? printf("最低分為:%d\n",Min);
? ? printf("平均分為:%d\n",Average);
? ? orderscore(score);
? ? return 0;
}