博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1098. Insertion or Heap Sort (25)
阅读量:4071 次
发布时间:2019-05-25

本文共 646 字,大约阅读时间需要 2 分钟。

提示 ,如果下一次排序完成的状态和上一次相同继续排列,最多排列N次。

#include 
#include
#include
#include
#include
#include
#include
using namespace std;void judge (vector
targetSequence,int pos,bool &kind){ for(int i=0; i
targetSequence[i+1]) { kind = false; break; } }}int main(){ int n; scanf("%d",&n); vector
initSequence(n); vector
targetSequence(n); for(int i=0; i
=0; --i) { if(initSequence[i]!=targetSequence[i]) { pos = i; break; } } bool isInsert = true; judge(targetSequence,pos,isInsert); vector
next = targetSequence; if(isInsert) { for(int i = pos+1;i
0; i--) { if(targetSequence[i]

转载地址:http://wqhji.baihongyu.com/

你可能感兴趣的文章
Python的getattr(),setattr(),delattr(),hasattr()
查看>>
js中的constructor与prototype
查看>>
Ajax中的get和post请求比较
查看>>
'VBoxManage' is not recognized as an internal or external command, operable program or batch file.
查看>>
Linux VNC server的安装及简单配置使用
查看>>
解决RHEL6 vncserver 启动 could not open default font 'fixed'错误.
查看>>
Linux 下路由的设置
查看>>
CentOS/Linux 网卡设置 IP地址配置
查看>>
Python实现ping指定IP
查看>>
linux下ping命令使用详解
查看>>
html引入jquery库
查看>>
js与jq比较
查看>>
js学习一数组类型foreach方法
查看>>
js学习二函数
查看>>
js学习三-日期Date
查看>>
js学习五-JSON
查看>>
linux下安装django
查看>>
Python django报错ImportError: cannot import name find_spec
查看>>
js学习六-闭包
查看>>
Django入门
查看>>