weixin_慕先生2217783
2021-08-03 15:38
#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;
}
#include <stdio.h>
#define N 10
int totalscore(int score[])
{
int total=0;//第1处修改
for(int i=0;i<10;i++)
{
//int total=0;此处错误1
total=total+score[i];
}
return total;
}
int maxscore(int score[])
{
int max=score[0];
for(int i=1;i<N;i++)//此处错误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++)//此处错误3
{
if(score[i]<min)
{
min=score[i];
}
}
return min;
}
double averagescore(int score[])
{
double average;//此处错误4,平均数最好用浮点数表示。
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++)//此处错误5
{
if(score[j-1]<score[j])//此处错误6
{
int temp;//此处错误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;
}
#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;
}
C语言入门
926019 学习 · 20793 问题
相似问题