博客
关于我
NC14661 简单的数据结构
阅读量:648 次
发布时间:2019-03-15

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

题目链接

题意

栗酱有一天在网上冲浪的时候发现了一道很有意思的数据结构题。

该数据结构形如长条形。
一开始该容器为空,有以下七种操作。

1 a从前面插入元素a

2 从前面删除一个元素

3 a从后面插入一个元素

4 从后面删除一个元素

5 将整个容器头尾翻转

6 输出个数和所有元素

7 对所有元素进行从小到大排序

思路

  • 根据题意模拟即可

参考代码

#include
using namespace std;int aa[200010];int main(){ int n,m; long long sum=0; cin>>n>>m; int index; int l=100000,r=100001; for(int i=0;i
>index; if(index==1) { int tmp; cin>>tmp; aa[l]=tmp; l--; } else if(index==2) { l++; } else if(index==3) { int tmp; cin>>tmp; aa[r]=tmp; r++; } else if(index==4) { r--; } else if(index==5) { for(int j=1;j<=(r-l)/2;j++) { swap(aa[l+j],aa[r-j]); } } else if(index==6) { cout<
<

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

你可能感兴趣的文章
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>