TheJin
2019-02-25 18:05
#include <stdio.h>
int sum(int score[],int value);
int max(int score[],int value);
int mini(int score[],int value);
float mean(int score[],int value);
void sort(int score[],int value);
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
sum(score,10);
max(score,10);
mini(score,10);
mean(score,10);
sort(score,10);
return 0;
}
int sum(int score[],int value)
{
int i,sum=0;
for(i=0;i<value;i++)
{
sum+=score[i];
}
printf("总分=%d\n",sum);
}
int max(int score[],int value)
{
int i,index=0;
for(i=0;i<value;i++)
{
if(score[i]>index)
{
index=score[i];
}
}
printf("最高分=%d\n",index);
}
int mini(int score[],int value)
{
int i,index=100;
for(i=0;i<value;i++)
{
if(score[i]<index)
{
index=score[i];
}
}
printf("最低分=%d\n",index);
}
float mean(int score[],int value)
{
int i;
float sum=0;
for(i=0;i<value;i++)
{
sum+=score[i];
}
sum/=value;
printf("平均分=%f\n",sum);
}
void sort(int score[],int value)
{
int i,j,index;
for(j=value;j>0;j--)
{
for(i=0;i<value;i++)
{
if(score[i]<score[i+1])
{
index=score[i];
score[i]=score[i+1];
score[i+1]=index;
}
}
}
printf("降序:");
for(i=0;i<value;i++)
{
if(i==0)
{
printf("%d",score[i]);
continue;
}
printf(">%d",score[i]);
}
printf("\n");
}
会对程序的稳定性产生影响吗
C语言入门
926210 学习 · 20797 问题
相似问题