有以下程序
void f(int n, int *r)
{int r1=0;
if(n%3==0) r1=n/3;
else if(n%5==0) r1=n/5;
else f(--n,&r1);
*r=r1;
}
main()
{int m=7,r;
f(m,&r); printf(“%d\n,r”);
}
程序运行后的输出结果是( )。
A.2
B.1
C.3
D.0
第1题:
给出以下程序的执行结果【 】。
include <iostream>
using namespace std;
int n=1;
void Fun();
int main ()
{
n++;
Fun ( );
if (n>0)
{
int n=5;
cout<<"Block: n="<<n<< ", ";
}
cout<< "Main: n="<<end1;
return 0;
}
void Fun ( )
{
int n=10;
cout<<"Fun: n="<<n<<",";
}
第2题:
阅读以下递归算法,画出递归调用示意图以及递归工作栈的每一步变化(拍照上传此题答案) int fact(int n) r1 { r2 if(n==0)f=1; r3 else f=n*fact(n-1); r4 return f; } int main() {... m=fact(3); r0 … }
第3题:
1、下面程序片段哪个没错?
A.int n = 4; int & r = n * 5;
B.int n = 6; const int & r = n; r = 7;
C.int n = 8; const int & r1 = n; int & r2 = r1;
D.int n = 8; int & r1 = n; const int r2 = r1;
第4题:
有以下程序: void f(int n,int * r) {int r1=0; if(n%3==0)r1=n/3; else if(n%5==0)r1=n/5; else f(--n,&r1); *r=r1;} main() {intm=7,r; f(m,&r);printf("%d\n",r);} 程序运行后的输出结果是______。
A.2
B.1
C.3
D.0
第5题:
下面程序片段哪个没错?
A.int n = 4; int & r = n * 5;
B.int n = 6; const int & r = n; r = 7;
C.int n = 8; const int & r1 = n; int & r2 = r1;
D.int n = 8; int & r1 = n; const int r2 = r1;