一.阅读程序回答问题
#include
using namespace std;
const int N=1e6+7;//第1行
int a[N],t[1024],n,m,id=1;
int main() {
cin>>n>>m;
for(int i=1;i>a[i];
t[a[i]]++;
}
for(int i=1000;i>=0;i--)
while(t[i]>0){
a[id++]=i;
t[i]--;
}
cout
using namespace std;
const int N=1e6+7;
int a[N],n,temp;
int main() {
cin>>n;
for(int i=1;i>a[i];
for(int ①;i>=2;i--){
bool ok=②;
for(int j=1;③;j++){
if(a[j]>a[j+1]){
ok=④;
⑤;
}
}
if(ok) break;
}
return 0;
}
- ①(){{ select(6) }}
- ②(){{ select(7) }}
- ③(){{ select(8) }}
- j
using namespace std;
const int N=1e6+7;
int a[N],n,temp;
int main() {
cin>>n;
for(int i=1;i>a[i];
for(①){
temp=a[i];
for(int j=i-1;②;j--){
if(③){
④=temp;
break;
}
swap(⑤,a[j+1]);
}
}
return 0;
}
11. ①{{ select(11) }}
- int i=1;i1;i--
12. ②(){{ select(12) }}
- j>1
- j!=1
- j>=1
- j>temp
13. ③(){{ select(13) }}
- a[j]>a[j+1]
- a[j]=temp
14. ④(){{ select(14) }}
- a[j]
- a[j+1]
- a[j-1]
- a[i]
15. ⑤(){{ select(15) }}
- a[j]
- temp
- a[j-1]
- j
---
## 四.阅读程序回答问题
```cpp
#include
using namespace std;
int fac(int x){
int res=0;
for(int i=2;i>n;
for(int i=0;i>a[i],b[i]=a[i];
for(int i=0;ifac(a[j+1])) continue;
else if(a[j]>a[j+1]) swap(a[j],a[j+1]);
}
}
sort(b,b+n,cmp);
for(int i=0;i R
- if(fac(L) != fac(R)) return L > R
- if(fac(L) != fac(R)) return fac(L) > fac(R)
- if(L != R) return fac(L) >fac(R)
18. (选择题)为了程序运行后,a数组和b数组一样,第10行应该填写( ){{ select(18) }}
- return L > R
- return L fac(R)
- return fac(L)
using namespace std;
int num[110],id[110];
int main() {
int n;cin>>n;
for(int i=1;i>num[i];
id[i]=i;
}
for(int i=1;i
using namespace std;
int a[1024];
int main() {
int n;cin>>n;
for(int i=1;i>a[i];
for(int i=2;itemp) pos=mid,R=mid-1;//第9行
else L=mid+1;
}
for(int j=i-1;j>=pos;j--) a[j+1]=a[j];//第12行
a[pos]=temp;
}
for(int i=1;i改成>=即可改成稳定排序算法( ){{ select(28) }}
- 对
- 错
29. (选择题)以下哪句代码可以代替第5行( ){{ select(29) }}
- for(int i=1;i=2;i--)
- for(int i=2;i<=n;i+=2)
30.(选择题)如果第6行的pos变量在定义时没有初始化,以下哪组数据能成功被排序?( ){{ select(30) }}
- 6 1 2 3 1 2 3
- 6 3 2 1 3 2 1
- 6 1 2 3 4 5 6
- 6 6 5 4 3 2 1
---