有兩個(gè)問題:1、想返回整個(gè)數(shù)組;2、為什么我現(xiàn)在這個(gè)代碼有返回值,但卻不是數(shù)組呢?幫幫忙
#include <stdio.h>
#define N 10
int totall(int score[]) ? //考試的總分
{
? ? int i,totall=0;
? ? for(i=0;i<N;i++)
{
? ? totall+=score[i];
}
return totall;
}
int Max(int score[])
{
? ? int i,max=0;
? ? for(i=0;i<N;i++)
{
? ? if(score[i]>max)
{
? ? max=score[i];
}
}
return max;
}
int Low(int score[])
{
? ? ?int i,min;
min=score[0];
for(i=0;i<N;i++)
{
? ? ?if(score[i]<min)
?min=score[i];
}
return min;
}
int average(int score[])
{
? ? ?int aver,sum;
sum=totall(score);
aver=sum/N;
return aver;
}
int sort(int score[])
{
?int i,j;
? ? ? for(i=8;i>=0;i--)
?for(j=0;j<=i;j++)
?{
?int temp;
? ? ?if(score[j]<score[j+1])
?{
? ? ? temp=score[j+1];
? score[j+1]=score[j];
? score[j]=temp;
?}
?}
?return score[N];
}
int main()
{
? ? int score[N]={67,98,75,63,82,79,81,91,66,84};
printf("總分是:%d\n",totall(score));
printf("最高分是:%d\n",Max(score));
printf("最低分是:%d\n",Low(score));
printf("平均分是:%d\n",average(score));
printf("考試成績(jī)降序排序:%d\n",sort(score));
? ? return 0;
}
2016-02-22
百度上有返回?cái)?shù)組的教程,雖然我看了會(huì)兒還是沒怎么看懂。
http://blog.163.com/guan123long@126/blog/static/131337312200993095721539/
2016-02-17
再試試 ? 會(huì)解決的