Keylogger Gym
来源:互联网 发布:linux epoll socket 编辑:程序博客网 时间:2024/05/21 21:34
blablabla: 好久不碰链表。。。但是感觉还可以
1.链表
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>using namespace std;char a[1000010];struct node{ char data; node *next; node *pre;};int main(){ int n; scanf("%d",&n); while(n --) { scanf("%s",a); int len = strlen(a); node *head,*tail,*p; head = new node; tail = head; tail->next = NULL; tail->pre = NULL; for(int i=0; i<len; i++)//一直就是因为srelen(a) 超时,每次都算 { if(a[i]=='<') { if(tail->pre) { tail = tail->pre; } } else if(a[i]=='>') { if(tail->next) { tail = tail->next; } } else if(a[i]=='-') { if(tail!=head) { if(tail->next) { tail->pre->next = tail->next; tail->next->pre = tail->pre; tail = tail->pre; } else { tail->pre->next = NULL; tail = tail->pre; } } } else { p = new node; p->data = a[i]; p->pre = tail; p->next = tail->next; tail->next = p; if(tail->next->next) { tail->next->next->pre = p; } tail = p; } } tail = head->next; while(head->next) { printf("%c",head->next->data); head = head ->next; } printf("\n"); } return 0;}
2.STL 顺序表
#include <bits/stdc++.h>using namespace std;int t;char s[2000000];list <char> ans;void output(){ for(list<char>::iterator it = ans.begin(); it!=ans.end();it++) printf("%c",*it); puts("");}int main(){ scanf("%d",&t); while(t--) { scanf("%s",s); ans.clear(); list<char>::iterator it, iter; for(int i=0,len = strlen(s); i<len;i++) { if(s[i]=='-') { if(ans.empty()||it==ans.begin()) continue; it--; it = ans.erase(it); } else if(s[i]=='<') { if(ans.empty()||it==ans.begin()) continue; it--; } else if(s[i]=='>') { if(ans.empty()||it==ans.end()) continue; it++; } else { if(ans.empty()) { ans.push_back(s[i]); it = ans.end(); } else { it = ans.insert(it,s[i]); it++; } } } output(); } return 0;}
阅读全文
0 0
- Keylogger Gym
- KeyLogger
- Good keylogger
- [C++]Ftp keylogger Code
- windows python keylogger
- 某Keylogger分析
- BAPC2010-I Keylogger
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- CodeForces
- JS基础五
- List集合的介绍与应用
- 感受异或的神奇
- java 基础(类与对象1)
- Keylogger Gym
- IO多路复用之epoll
- makefile--工程管应用理器的简单
- OSPF
- HashSet
- vue动态数据绑定3--深层次数据变化逐层往上传播
- [caioj]【计算几何】判断线段相交(跨立实验) 计算几何 叉积
- [Poi2014]FarmCraft 树状dp
- Word Search问题及解法