70,008
社区成员




#define NUM 20
...
int score[NUM];
...
double getAver(int score[])
{
//利用NUM求平均数
}
static inline int
scan_ordinary(struct asyncppp *ap, const unsigned char *buf, int count)
{
int i, c;
for (i = 0; i < count; ++i) {
c = buf[i];
if (c == PPP_ESCAPE || c == PPP_FLAG
|| (c < 0x20 && (ap->raccm & (1 << c)) != 0))
break;
}
return i;
}
#include<stdio.h>
int getAvgScore(int score[])
{
int *p;
int num=0;
int sum=0;
p=score;
while((*p)!=-1)
{
sum+=*p;
num++;
p++;
}
return sum/num;
}
int main()
{
int score[]={10,20,30,40,50,60,70,80,-1};//此处-1作为数组结束标志
int a=0;
a=getAvgScore(score);
printf("a=[%d]\n",a);
}