每次仅可将数组元素加1,计算将数组变为非递减所需最少操作次数的C++代码空缺处应填入哪一项?
#include<iostream>
usingnamespace std;
int a[1000];int main(){
int n, cnt = 0;
cin >> n;
for (inti= 0; i<n; i++) cin >> ali];
for (int i= 1;i< n; i++){
if (a[i - 1]> a[i]) {
cnt += ① ;
②_;
}
}
cout << cnt;
return 0;
}
正在加载题目数据…
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析