举一反三
- 以下程序的输出结果是______。#include [stdio.h]int f(int a[ ],int n){ if(n>1)return a[0]+f(&a[1],n-1);else return a[0];}int main(){ int aa[3]={1,2,3},s;s=f(&aa[0],3);printf(“%d\n”,s);return 0; }
- 下面程序的运行结果是______。#include int f(int a[],int n) if(n>1)return a[0]+f(a+1,n-1);elsereturn a[0];main() int aa[10]=1,2,3,4,5,6,7,8,9,10,s;s=f(aa+2,4); printf("%d\n",s);
- 下列程序的输出结果是 。#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);}
- 下面程序的运行结果是:____。int f( int a[ ], int n){if(n>1)return a[0]+f(&a[1],n-1);elsereturn a[0];}main ( ){int aa[3]={1,2,3},s;s=f(&aa[0],3);printf("%d\n",s);}
- 有以下程序,程序运行后的输出结果是( )。#includeint f(int t[],int n);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;} A: 4 B: 10 C: 14 D: 6
内容
- 0
下列程序的运行结果是?#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
- 1
以下程序运行后的输出结果是_______。#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));}
- 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;}
- 3
#include int f(int t[],int n); main() {int a[4]={1,2,3,4},s; s=f(a,4); printf(“%d”,s); } int f(int t[],int n) {if (n>0) return t[n-1]+f(t,n-1); else return 0;} 程序运行后的输出结果是
- 4
下面程序执行的结果是 。#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);}