以下程序调用函数的顺序为()#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: f1->f2->f3->f4
B: f1->f2->f3
C: f1->f2->f4
D: f4->f3->f2->f1
举一反三
- 下列程序的运行结果是?#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
- 中国大学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;}
- 以下程序运行后的输出结果是________。 #include "stdio.h" int f(int x); void main() { int n=1,m; m=f(f(f(n))); printf("%d",m); } int f(int x) {return x*2;}: 1/#/2/#/4/#/8
- 下面程序执行的结果是 。#include<;stdio.h>;int f(int );int main(){int z;z=f(5);printf("%d\n",z);return 0;}int f(int n){if(n==1||n==2)return 1;elsereturn f(n-1)+f(n-2);}
- 下列程序的输出结果是 。#includeint f(int t[], int n);void main(){int a[4]={1, 2, 3, 4}, s;s=f(a, 4); printf("%d\n", s);}int f(int t[], int n){if(n>;0) return(t[n-1]+f(t,n-1));else return(0);}