📄 compute.c
字号:
void ave_student(int score[10][5] ,float ave[10])//①每个学生的平均分;
{//计算出的平均分放在ave数组中
int i,j;
for(i=0;i<10;i++)
{
ave[i]=0;
for(j=0;j<5;j++)
ave[i]+=score[i][j];
ave[i]/=5;
}
}
void ave_subject(int score[10][5],float ave[5])//②每门课的平均分;
{//计算出的平均分放在ave数组中
int i,j;
for(i=0;i<5;i++)
{
ave[i]=0;
for(j=0;j<10;j++)
ave[i]+=score[j][i];
ave[i]/=10;
}
}
void top_subject(int score[10][5],int top_index[5])//③找出最高的分数对应的学生和课程
{//经过以下计算后,每门课的最高分学生的序号放在了top_index中
int i,j;
int top_score=0;
for(i=0;i<5;i++)
{
top_score=0;
for(j=0;j<10;j++)
{
if(top_score<score[j][i])
{
top_score=score[j][i];
top_index[i]=j;
}
}
}
}
void sort_subject(int score[10][5],float total[5],int index[5])//④每门课程的总分并按降序排列;
{//计算后,total存放每门课的总分,index存放相应科目的排序
int i,j;
for(i=0;i<5;i++)//count average
{
total[i]=0;
index[i]=0;
for(j=0;j<10;j++)
total[i]+=score[j][i];
}
for(i=0;i<5;i++) //sort
{
for(j=i+1;j<5;j++)
{
if(total[i]>=total[j])
index[j]+=1;
else
index[i]+=1;
}
}
}
void find_fail(int score[10][5],int name[10][5])//⑤找出有不及格成绩的学生及对应的课程。
{//经过以下计算,name数组中的元素标志了相应位置是否不及格
//例如:name[3][2]==0,则说明第4(=3+1)个学生的第3(=2+1)科不及格
int i,j;
for(i=0;i<10;i++)
for(j=0;j<5;j++)
{
if(score[i][j]<60)name[i][j]=0; //fail ,not pass
else name[i][j]=1; //pass
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -