大佬們,幫忙看看有什么問題
#include <stdio.h>
int main()
{
? ? int N=10;
? ? int score[N]={67,98,75,63,82,79,81,91,66,84};
? ? int i;
? ? int max=score[0];
? ? int min=score[0];
? ? int sum=0;
? ? for(i=0;i<10;i++)
? ? {
? ? ? ? sum=sum+score[i];
? ? ? ? if(max<score[i])
? ? ? ? {
? ? ? ? ? ? max=score[i];
? ? ? ? }
? ? ? ? if(min>score[i])
? ? ? ? {
? ? ? ? ? ? min=score[i];
? ? ? ? }
? ? ? ?
? ? }?
? ? double pjf=sum/10;
? ? int tem,j,f,z;
? ? for(f=0;f<8;f++)
? ? {
? ? ? for(j=0;j<9;j++)
? ? ? {
? ? ? ? ?tem=score[j];
? ? ? ?
? ? ? ? if(score[j]<score[j+1])
? ? ? ? {
? ? ? ? ? ? score[j]=score[j+1];
? ? ? ? ? ? score[j+1]=tem;
? ? ? ? }??
? ? ? }
? ??
? ? ? ?
? ? ? ??
? ? ? ??
? ? }
? ??
? ? printf("考試總分=%d\n",sum);
? ? printf("最高分=%d\n",max);
? ? printf("最低分=%d\n",min);
? ? printf("平均分=%f\n",pjf);
? ? for(z=0;z<10;z++)
? ? {
? ? ? ? printf("考試成績=%d\n",score[z]);
? ? }
? ?
? ??
? ??
? ? return 0;
}
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;
}