1 #include<stdio.h> 2 #include<string.h> 3 #include<stddef.h> 4 #include<stdarg.h> 5 float average(int values_,...) { 6 va_list var_; 7 int i = 0; 8 float sum = 0; 9 va_start(var_, values_); 10 for (i = 0; i < values_; i++) 11 { 12 sum += va_arg(var_, int); 13 } 14 va_end(var_); 15 return sum / values_; 16 } 17 int main() 18 { 19 float a, b; 20 a = average(3, 1, 2, 3); 21 b = average(5, 1, 2, 6, 4, 3); 22 printf("%f,%f\n", a, b); 23 return 0; 24 }
标签:va,为例,int,平均数,float,列表,values,var,include From: https://www.cnblogs.com/alexlance/p/17429171.html