哪錯了哪錯了
#include <stdio.h>
int main()
{
? ? int score[10]={67,98,75,63,82,79,81,91,66,84};
? ? printf("總分是%d\n最高分是%d\n最低分是%d\n平均分是%f\n",
? ? zongfen(score[10]),zuigao(score[10]),zuidi(score[10]),pingjun(score[10]));
? ? return 0;
}
int zongfen(score)
{
? ? int sum=0;
? ? int a=0;
? ? if(a<10;a++)
? ? {
? ? ? ? sum+=score[a];
? ? ? ? a++;
? ? }
? ? return sum;
}
int pingjun(score)
{
? ? int sun=0;
? ? int b=0;
? ? if(b<10;b++)
? ? {
? ? ? ? sun+=score[b];
? ? }
? ? return sun/10;
}
int zuigao(score)
{
? ? int c=0;
? ? int max=score[0];
? ? for(c<10;c++)
? ? {
? ? ? ? if(max<score[c])
? ? ? ? {
? ? ? ? ? ? max=score[c];
? ? ? ? }
? ? }
? ? return max;
}
int zuidi(score)
{
? ? int d=0;
? ? int min=score[0];
? ? for(d<10;d++)
? ? {
? ? ? ? if(min>score[d])
? ? ? ? {
? ? ? ? ? ? min=score[d];
? ? ? ? }
? ? }
? ? return min;
}
2022-02-10
#include <stdio.h>
#define N 10
int main()
{
? ? int score[N]={67,98,75,63,82,79,81,91,66,84};
? ? int i,j;
? ? int Max=0,Min=score[0],temp;
? ? float Mid=0,Sum=0;
? ? for(i=0;i<N;i++)Sum+=score[i]; //總成績
? ? Mid=Sum/N;//平均分
? ? for(i=0;i<N;i++)
? ? {
? ? ? ? if(score[i]>Max)Max=score[i]; //最高
? ? ? ? if(score[i]<Min)Min=score[i]; //最低
? ? }
? ? for(i=N-1-1;i>=0;i--)//冒泡排序N-下標-1
? ? {
? ? ? ? for(j=0;j<=i;j++)//前一個與后一個比較,直到最后
? ? ? ? {
? ? ? ? ? ? if(score[j]<score[j+1])//前一個小于后一個則進行交換
? ? ? ? ? ? {
? ? ? ? ? ? ? ? temp=score[j];
? ? ? ? ? ? ? ? score[j]=score[j+1];
? ? ? ? ? ? ? ? score[j+1]=temp;
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? }
? ? ? ?
? ? }
? ? printf("總分:%.1f分\n最高分:%d分\n最低分:%d分\n平均分:%.1f分\n",Sum,Max,Min,Mid);
? ? printf("冒泡法降序排序:");
? ? for(i=0;i<N;i++)
? ? ? ? printf("%d ",score[i]);
? ? ? ??
? ? return 0;
}