#include<stdio.h>
#include<stdarg.h>
int average(int num,...)
{
int i=0;
int sum=0;
va_list arg;
va_start (arg,num);
for(i=0; i<num; i++)
{
sum+=va_arg (arg, int);
}
va_end(arg);
return sum/num;
}
int main()
{
int avg;
avg=average(5,1,2,3,4,5);
printf("%d ",avg);
return 0;
}
转载于:https://blog.51cto.com/green906/1707328