【填空题】写出下面程序执行后的运行结果____。#include int SUM( int n ){ if ( n == 1 ) return(1); else return(n * n + SUM( n - 1 ) );} int main(){ printf( "SUM=%d", SUM( 5 ) ); return(0);}
查看答案
【填空题】函数fun的功能是计算xn double fun( double x, int n ){ int i; double y = 1; for ( i = 1; i <= n; i++ ) y = y * x; return(y);}主函数中已经正确定义m,a,b变量并赋值,调用fun函数计算:m=a4+b4-(a+b)3的调用语句为、____
【填空题】写出下面程序执行后的运行结果____。#include int f1( int x, int y ){ return(x > y ? x : y);} int f2( int x, int y ){ return(x > y ? y : x);} int main(){ int a = 4, b = 3, c = 5, d = 2, e, f, g; e = f2( f1( a, b ), f1( c, d ) ); f = f1( f2( a, b ), f2( c, d ) ); g = a + b + c + d - e - f; printf( "%d,%d,%d", e, f, g ); return(0);}
【填空题】可以将被调函数中获得的值返回给主调函数的语句是____。
【填空题】写出下面程序执行后的运行结果____。#include void fun( int *a, int i, int j ){ int t; if ( i < j ) { t = a[i]; a[i] = a[j]; a[j] = t; i++; j--; fun( a, i, j ); }} int main(){ int x[] = { 2, 6, 1, 8 }, i; fun( x, 0, 3 ); for ( i = 0; i < 4; i++ ) printf( "%d", x[i] );return(0);}