有以下程序
#include <stdio.h>
void fun( char. c)
{ if(c>'x') fun( c-1);
printf("%c",c);
}
main( )
{ fun(’z’); }
程序运行后的输出结果是
A) xyz
B) wxyz
C) zyxw
D)zyx
第1题:
下面程序的运行结果是( )。
include<stdio.h>
main()
{int a=25;
fun(&A);
}
fun(int *x)
{ printf("%d\n",++*x);
}
第2题:
有以下程序: #include <stdio.h> char fun(char x,char y) { if(x<y) return x; return y; } main() { int a='9',b='8',c='7'; printf("%c\n",fun(fun(a,b),fun(b,c))); } 程序的执行结果是( )。
A.函数调用出错
B.8
C.9
D.7
第3题:
有以下程序: #include <stdio.h> fun(int x,int y,int z) { z=x*y;} main() { int a=4,b=2,c=6; fun(a,b,c); printf("%d",c); } 程序运行后的输出结果是( )。
A.16
B.6
C.8
D.12
第4题:
下列程序的输出结果是【 】。
include <stdio.h>
void fun(int x)
{
if(x/2>0) fun(x/2);
printf("%d",x);
}
main()
{
fun(3);printf("\n");
}
第5题:
有以下程序:
include<stdio.b>
void fun(char c)
{ if(c>X)fun(c-1):
printf("%C",c);
}
traia( )
{ fun(z);}
程序运行后的输出结果是( )
A.xyz
B.wxyz
C.xzy
D.zvx
本题考查简单的递归函数,当c>X则会产生递归,依次类推,答案选择A.