我這個(gè)哪錯(cuò)了?。??????
#include <stdio.h>
int a()
{
??? int score[10]={67,98,75,63,82,79,81,91,66,84};
??? int sum=0;
??? int N;
??? for(N=0;N<10;N++)
??? {
??????? sum+=score(N);
??? }
??? printf("考試的總分為%d\n平均分為%d\n", sum, sum/10);
??? return 0;
}
int b()
{
??? int score[10]={67,98,75,63,82,79,81,91,66,84};
??? int i, max;
??? max=score[0];
??? for(i=0;i<9;i++)
??? {
??????? if(score(i)>max)
??????? {
??????????? max=score(i);
??????? }
??? }
??? printf("最高分為%d\n", max);
??? return 0;
}
int c()
{
??? int score[10]={67,98,75,63,82,79,81,91,66,84};
??? int j, min;
??? min=score[0];
??? for(j=0;j<9;j++)
??? {
??????? if(score(j)<min)
??????? {
??????????? min=score(j);
??????? }
??? }
??? printf("最低分為%d\n", min);
??? return 0;
}
int d()
{
??? int score[10]={67,98,75,63,82,79,81,91,66,84};
??? int temp, x, y;
??? for(x=0;x<9;x++)
??? {
??????? for(y=0;y<9-x;y++)
??????? {
??????????? temp=score(y);
??????????? if(score(y)<score(y+1))
??????????? {
??????????????? temp=score(y+1);
??????????????? score(y+1)=score(y);
??????????? }
??????? }
??? }
??? printf("考試成績(jī)降序排列為:\n");
??? for(y=0;y<10;y++)
??? {
??????? printf("%d", score(y));
??? }
??? return 0;
}
int main()
{
??? a();
??? b();
??? c();
??? d();
??? return 0;
}
2019-12-02
#include <stdio.h>
int sum=0;
int main()
{
? ? int score[10]={67,98,75,63,82,79,81,91,66,84};
//對(duì)一位數(shù)組進(jìn)行冒泡排序
? ? int a,b;
int temp=0;
for(a=0;a<10-1;a++)
{
for(b=0;b<10-1-a;b++)
if(score[b]<score[b+1])
{
temp=score[b];
score[b]=score[b+1];
score[b+1]=temp;
}
}
//求總分
{
for(a=0;a<10;a++)
sum=sum+score[a];
printf("總分=%d\n",sum);
}
//最低分
{
printf("最低分=%d\n",score[9]);
}
//最高分
{
printf("最高分=%d\n",score[0]);
}
//平均分
{
float average;
average=sum/10;
printf("平均分=%.2f\n",average);
}
//成績(jī)排序
for(a=0;a<10;a++)
printf("第%d名分?jǐn)?shù)%d\n",a+1,score[a]);
return 0;
}
2019-11-15
都是語(yǔ)法錯(cuò)誤。不過(guò)排序還是有問(wèn)題,這個(gè)你應(yīng)該好解決的