#include <stdio.h>
#define N 10
int total(int score[])
{
int i;
int sum;
for(i=0;i<=9;i++)
{
sum+=score[i];
}
return sum;
}
int Max(int score[])
{
int i;
int max;
//int a;
for(i=0;i<=9;i++)
{
if(max<score[i])
{
max = score[i];
}
/* a=score[i+1]>score[i]?score[i+1]:score[i];
max=max>a?max:a;*/
}
return max;
}
int Min(int score[])
{
int i;
int min;
//int b;
for(i=0;i<=9;i++)
{
if(min>score[i])
{
min = score[i];
}
/* b=score[i+1]<score[i]?score[i+1]:score[i];
min=score[i+2]<b?score[i+2]:b;*/
}
return min;
}
float Ave(int sum)
{
return (sum+0.0)/N;
}
int main()
{
int score[N]={2,11,28,10,30,6,22,8,9,10};
int sum;
int i,j;
int temp;
sum=total(score);
printf("Total score:%d\n",sum);
printf("Max score:%d\n",Max(score));
printf("Min score:%d\n",Min(score));
printf("Average score:%.1f\n",Ave(sum));
puts("changed:");
for(j=1;j<N;j++)
{
for(i=1;i<N-j;i++)
{
if(score[i]>score[i+1])
{
temp=score[i];
score[i]=score[i+1];
score[i+1]=temp;
}
}
}
for(i=0;i<=9;i++)
{
printf("%d\n",score[i]);
}
return 0;
}
望远
慕的地6079101
閞始慬孒
他们都说我宅
望远
Devil10
相关分类