#include <stdio.h>
int tp(int score[])
{
int sum;
int i;
for(i=0;i<10;i++)
{
sum=sum+score[i];
}
return sum;
}
int max(int score[])
{
int i;
int max=-1;
for(i=0;i<10;i++)
{
if(score[i]>max)
{
max=score[i];
}
}
return max;
}
int min(int score[])
{
int i;
int min=100;
for(i=0;i<10;i++)
{
if(score[i]<min)
{
min=score[i];
}
}
return min;
}
int mean(int score[])
{
int num;
int i;
for(i=0;i<10;i++)
{
num=num+score[i];
}
num/=10;
return num;
}
int ranking(int score[])
{
int i,j;
for(i=8;i>=0;i--)
{
for(j=0;j>=0;j++)
{
int index;
if(score[j]<score[j+1])
index=score[j];
score[j]=score[j+1];
score[j+1]=index;
}
}
for(i=0;i<10;i++)
{
return score[i];
}
}
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
return 0;
int sum;
sum=tp(score);
printf("总分是%d\n",sum);
}
#include <stdio.h>
int N=10;
/*求和函数*/
int totalPoints(int score[N])
{
int i;
int sum=0;
for(i=0;i<N;i++)
{
sum+=score[i];
}
return sum;
}
/*求最高分函数*/
int topScore(int score[N])
{
int i=0;
int max;
max=score[0];
for(i=1;i<N;i++)
{
if(score[i]>max)
max=score[i];
}
return max;
}
/*求最低分函数*/
int lowScore(int score[N])
{
int i=0;
int min;
min=score[0];
for(i=1;i<N;i++)
{
if(score[i]<min)
min=score[i];
}
return min;
}
/*求平均分函数*/
int averScore(int score[N])
{
return totalPoints(score)/N;
}
/*冒泡法排序*/
void descendSort(int score[N])
{
int i,j;
printf("=====================排序前=======================\n");
for(i=0;i<N;i++)
printf("%d ",score[i]);
for(i=8;i>=0;i--)
{
for(j=0;j<=i;j++)
{
if(score[j]<score[j+1])
{
int temp;
temp=score[j+1];
score[j+1]=score[j];
score[j]=temp;
}
}
}
printf("\n=====================排序后=======================\n");
for(i=0;i<N;i++)
printf("%d ",score[i]);
}
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
printf("总分是:%d\n",totalPoints(score));
printf("最高分是:%d\n",topScore(score));
printf("最低分是:%d\n",lowScore(score));
printf("平均分是:%d\n",averScore(score));
descendSort(score);
return 0;
}