举一反三
- 写出下列程序的执行结果是:__________________。#include<;iostream>;using 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;}
- 1、写出下列程序的输出结果 #include [iostream] using namespace std; int b=2; int func(int *a) { b+=*a; return(b); } int main( ) { int a=2,res=2; res+=func(&a); cout<<res<<endl; return 0; }
- 有以下程序: #include<iostream> using namespace std; int f(int,int); int main() { int i:1,x; x=f(i,i+1); cout<<x<<end1; return 0; } int f(int a,int b) { int c; c = a; if(a>b) c = 1; else if(a==b) c = 0; else c = -2; return c; } 运行后的输出结果是 。 A: 1 B: 0 C: -1 D: -2
- 写出下列程序的执行结果是:__________________。#include<;iostream>;using 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 );}
- 阅读以下程序,a的值为#include<stdio.h>int a;int f1(int b, int c, int d);int f2(int b, int c);int f3(int b);int f1(int b, int c, int d) { return f2(b*c, d);}int f2(int b, int c) { return f3(b*c);}int f3(int b) { a = b; return a == 32;}int main() { int b = 2, c = 4, d = 8, ans; a = 1; ans = f1(b, c, d); return 0;} A: 1 B: 2 C: 32 D: 64
内容
- 0
有以下程序 int f1(int x,int y) {return x>y?x:y;} int f2(int x,int y) {return x>y?y:x;} 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\n",e,f,g); } 程序运行后的输出结果是()
- 1
写出下列程序的执行结果是:__________________。[br][/br]#include[br][/br]using namespace std;[br][/br]int f2( int, int );[br][/br]int f1( int a , int b )[br][/br]{ [br][/br] int c ;[br][/br] a += a ; b += b ;[br][/br] c = f2( a+b , b+1 );[br][/br] return c;[br][/br]}[br][/br]int f2( int a , int b )[br][/br]{ [br][/br] int c ;[br][/br] c = b % 2 ;[br][/br] return a + c;[br][/br]}[br][/br]void main()[br][/br]{ [br][/br] int a = 3 , b = 4;[br][/br] cout [< f1( a , b ) << endl;<br]}
- 2
中国大学MOOC: 以下程序调用函数的顺序为()#include<stdio.h>int f1(int a, int b);int f2(int a, int b);int f3(int a, int b);int f4(int a, int b);int main() { int a, b,ans; a = 1; b = 2; ans = f1(a, b);}int f1(int a, int b) { return f2(a,b);}int f2(int a, int b) { if (a>b) return f3(a, b); return f4(a, b);}int f3(int a, int b) { return a - b;}int f4(int a, int b) { return b - a;}
- 3
运行下列程序,第1行输出是____,第2行输出是____,第3行输出是____。 #include[ iostream ] using namespace std; int a, b(1); int main( ) { int a=2; { int a=3; a+=10; b+=10; cout<<a+b<<endl; } a+=100; b+=100; cout<<a+b<<endl; cout<<::a+::b<<endl; return 0; }
- 4
下面程序的运行结果是_______。#include<stdio.h>int main( ){ int f1( int x , int y ) ;int a = 11 , b = 12 ,c ;c = f1( a , b ) ;printf( "a=%d,b=%d,c=%d\n" , a , b ,c ) ;return 0 ;}int f1( int x , int y ){ int f2( int , int ) ;int c ;x = x * 2 ;y = y * 2 ;c = f2( x , y ) ;return c*2 ;} int f2( int a , int b ){int c ;c = ( a + b ) % 3 ;return c ;}