正在加载图片...
8.3.3数组名作为函数的参数数组元素作为函数实参时,函数形参为变量与变量作为函数实参相同,值传递 double fact (int n)double fact (int n); int i;int main(void )(double result = 1:int a[5]=[1, 4, 5, 7, 9];for (i = 1;i<= n; i++)int i, n = 5;result = result *i;double sum;return result ;sum = 0;人for(i = 1; i<= n; i++ )sum = sum + fact(a[i-1]);printf("sum = %eln", sum);1!+4!+5!+7!+9!return O;数组元素作为函数实参时,函数形参为变量 与变量作为函数实参相同,值传递 8.3.3 数组名作为函数的参数 double fact (int n); int main(void ) { int i, n = 5; double sum; sum = 0; for(i = 1; i <= n; i++ ) sum = sum + fact (i); printf("sum = %e\n", sum); return 0; } double fact (int n) { int i; double result = 1; for (i = 1; i <= n; i++) result = result * i ; return result ; } int a[5]={1, 4, 5, 7, 9}; fact(a[i-1]); 1!+4!+5!+7!+9!
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有