#5003. [客观题]递归
[客观题]递归
一.选择题
- 代码的运行结果是
int fun(int x){
double y=x;
return y/2;
}
int main(){
int a=5;
coutres) res=x[i];
}
return res;
}
int a[6]={1,2,3,9,8,7};
{{ select(6) }}
- func(*a,6)
- func(a[ ],6)
- func(a,6)
- func(a[6],6)
- 代码的运行结果是
void func(int x){
if(x==0) return;
func(x/2);
cout
using namespace std;
① func(string m,int a,int b){
if(②) return;
int num=int (m.back());//m.back()是指字符串m的最后一个字符
if(num>='0' && num>s;
int k;cin>>k;
cout>str;
int N=str.size();
if(N & 1) coutr)
* if(str[l]!=str[r])
* if(str[l]==str[r])
* if(l==r)
## 四.阅读程序回答问题
函数f1和函数f2有相同的作用,如果传入的参数一样,那么f1和f2会有相同的返回值(在输入数据在正确范围的情况下).阅读f1和f2,回答问题
```cpp
int f1(int m,int n){
if(m==0 || n==1) return 1;
if(m
using namespace std;
int ans[10],n,m;
void dfs(int x){
if(①){
bool s=②;
for(int i=1;i>n>>m;
dfs(⑤);
return 0;
}
- ①{{ select(31) }}
- x==n
- x==m
- x>n
- x>m
- ②{{ select(32) }}
- True
- true
- False
- false
- ③{{ select(33) }}
- True
- true
- False
- false
- ④{{ select(34) }}
- ans[i]=x
- ans[x]=i
- anx[i]++
- ans[x]++
- ⑤{{ select(35) }}
- 0
- 1
- n
- m
六.阅读程序回答问题
#include
using namespace std;
int a[30], t[30];
void mgsort(int L, int R) {
int mid = (L + R) / 2;
if (L != mid) mgsort(L, mid); //第4行
if (mid + 1 != R) mgsort(mid + 1, R); //第5行
int i = L, j = mid + 1, index = L;
while (i > n;
for (int i = 1; i > a[i];
mgsort(1, n);
for (int i = 1; i <= n; i++) cout << a[i] << ' ';
return 0;
}
- (判断题) 该代码是一种升序的排序算法( ){{ select(36) }}
- 对
- 错
- (判断题) 该代码是一种稳定的排序算法( ){{ select(37) }}
- 对
- 错
- (判断题) 交换第4第5行代码,不影响原来的输出{{ select(38) }}
- 对
- 错
39.(选择题) 如果该程序正常运行,mgsort()函数大约要被调用多少次( ){{ select(39) }}
- n
- n*n
- 2*n
- log2n
- (选择题) 第9行代码等价于{{ select(40) }}
- t[index]=a[j];index++;j++;
- index++;t[index]=a[j];j++;
- index++;j++;t[index]=a[j];
- j++;t[index]=a[j];index++;