写出下列程序的执行结果是:__________________。#includeusing namespace std;int f1( int a, int b ) { return a + b ;}int f2( int a, int b ){ return a - b ;}int f3( int( *t )( int, int ), int a, int b ) { return ( *t )( a, b ) ;}void main(){ int ( *p )( int, int ); p = f1 ; cout << f3( p, 4, 8 ) <<","; p = f2 ; cout << f3( p, 8, 4 );}
查看答案
写出下列程序的执行结果是:__________________。#includeusing namespace std;int f2( int, int );int f1( int a , int b ){ int c ; a += a ; b += b ; c = f2( a+b , b+1 ); return c;}int f2( int a , int b ){ int c ; c = b % 2 ; return a + c;}void main(){ int a = 3 , b = 4; cout << f1( a , b ) << endl;}
写出下列程序的执行结果是:__________________。#includeusing namespace std;void func( int * p, int * q, int *& x) ;void main(){ int a=10, b=20; int *p=&a, *q=&b; func( p, q, p );}void func( int *t1 , int *t2 , int *& rt ){ *t1 += 5 ; *t2 += 5 ; rt = t1 ; *rt += 5 ; cout << "*t1=" << *t1 << ",*t2=" << *t2<< ",*rt=" << *rt << endl;}
写出下列程序的执行结果是:__________________。#includeusing namespace std;void func( int *, int *, int *& ) ;void main(){ int a=10, b=20; int *p=&a, *q=&b; func( p, q, p ); cout << "*p=" << *p << ",*q=" << *q << endl;}void func( int *t1 , int *t2 , int *& rt ){ *t1 += 5 ; *t2 += 5 ; rt = t1 ; *rt += 5 ; }
写出下列程序的执行结果是:__________________。#includeusing namespace std;void func( int, int, int & );void main(){ int x=0 , y=1 , z=2; func( 1 , 2 , x ); func( x + y , y , y ); func( z , x + y , z ); cout << x << "," << y << ","<< z << endl ;}void func( int a , int b , int &c ){ b += a ; c = b - a ; }