以下程序运行后的输出结果是_______。#include<;stdio.h>;int f(int n){if(n==0||n==1) return 1;elsereturn n+f(n-1);}int main(){printf(“%d\n”,f(0));printf(“%d\n”,f(1));printf(“%d”,f(5));}
举一反三
- 下面程序执行的结果是 。#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);}
- 以下程序的输出结果是______ 。#include int f(int n) { if(n == 1) return 1; else return n + f(n - 1);}int main(void) { printf("%d\n", f(5)); return 0;}
- 执行以下程序后,如果输入为1,则输出为,如果输入为0,则输出为,如果输入为4,则输出为。#include<;stdio.h>;int f(int n);int main(){int n;scanf("%d",&n);printf("%d\n",f(n));return 0;}int f(int n){if(n==0||n==1)return 1;elsereturn f(n-1)+f(n-2);}
- 下列程序的运行结果是?#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<;stdio.h>;int n=0;void f();int main(){int n;n=2;f();printf("%d\n",n);return 0;}void f(){n=n+5;printf("%d\n",n);}