中国大学MOOC: 以下程序调用函数的顺序为()#includeint 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;}
举一反三
- 以下程序调用函数的顺序为()#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;} A: f1->f2->f3->f4 B: f1->f2->f3 C: f1->f2->f4 D: f4->f3->f2->f1
- 阅读以下程序,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
- 下列程序的运行结果是?#include [stdio.h] int f(int n); int main() { printf("%d\n", f(f(f(f(1))))); return 0; } int f(int n) { return n + 1; } A: 5 B: 4 C: 3 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 );}
- 有以下程序 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); } 程序运行后的输出结果是()