博客
关于我
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/

你可能感兴趣的文章
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No qualifying bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>‘ available
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No static resource favicon.ico.
查看>>
no such file or directory AndroidManifest.xml
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
no1
查看>>
NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
查看>>
NOAA(美国海洋和大气管理局)气象数据获取与POI点数据获取
查看>>
NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
查看>>
node exporter完整版
查看>>
node HelloWorld入门篇
查看>>
Node JS: < 一> 初识Node JS
查看>>
Node JS: < 二> Node JS例子解析
查看>>
Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime(72)
查看>>
Node 裁切图片的方法
查看>>
Node+Express连接mysql实现增删改查
查看>>