//形参1释义:指明“若干”是几
#include<stdio.h>
#include<stdarg.h>
unsigned GCD(unsigned a,unsigned b)
{
return b?GCD(b,a%b):a;
}
unsigned gcd(int nterm, ...)
{
unsigned gcd=0;
int i;
va_list p;
va_start(p,nterm);
for(i=1;i<=nterm;i++)
{
gcd=GCD(va_arg(p,unsigned),gcd);
}
va_end(p);
return gcd;
}
main( )
{
printf("%d\n",gcd(2,15,36));
printf("%d\n",gcd(4,480,216,360,1296));
}
落霞与孤鹜齐飞,秋水共长天一色! 心有多大,路有多宽。三教九流,鸡鸣狗盗。兼收并蓄,海纳百川。