uva 11988
来源:互联网 发布:淘宝一千零一夜在哪 编辑:程序博客网 时间:2024/05/01 01:42
这其实是一道很简单的模拟题,方法都相近,可能用数学的思维解比较巧妙,不过直白点就用链表模拟,可是由于最近没怎么做题了,一直WA,傻逼的没发现很白的错误,诶,看来做什么都是要持之以恒的,如果只是三天打鱼两天晒网,是根本不可能有什么太大收获,一定要好好做题了。
#include<cstdlib>#include<cstdio>#include<cstring> using namespace std;struct list{ char c; struct list*nextptr;};struct list *headptr,*leftptr,*rightptr,*currentptr,*temp;int flag;void deal(char ch){ temp=(list*)malloc(sizeof(list)); temp->c=ch; temp->nextptr=NULL; if(flag==1){ if(headptr==NULL){ headptr=temp; currentptr=headptr; } else{ currentptr->nextptr=temp; currentptr=currentptr->nextptr; } } if(flag==2){ if(headptr==NULL){ headptr=temp; currentptr=temp; leftptr=temp; rightptr=NULL; } else{ if(leftptr==NULL){ leftptr=temp; leftptr->nextptr=headptr; rightptr=headptr; headptr=leftptr; } else{ leftptr->nextptr=temp; temp->nextptr=rightptr; leftptr=temp; } if(currentptr->nextptr!=NULL)currentptr=currentptr->nextptr; } }}int main(){ char str[100005]; headptr=NULL,leftptr=NULL,rightptr=NULL,currentptr=NULL; flag=1; while(scanf("%s",str)!=EOF){ int len=strlen(str); for(int i=0;i<len;i++){ if(str[i]=='['){ flag=2; leftptr=NULL,rightptr=NULL; } else if(str[i]==']')flag=1; else{ deal(str[i]); } } currentptr=headptr; while(currentptr!=NULL){ printf("%c",currentptr->c); currentptr=currentptr->nextptr; } headptr=NULL,leftptr=NULL,rightptr=NULL,currentptr=NULL; flag=1; printf("\n"); } return 0;}
- UVA 11988
- UVA 11988
- uva 11988
- uva 11988
- UVa 11988
- uva 11988
- UVA - 11988
- UVA 11988
- [UVA]11988
- uva 11988
- Uva 11988 Broken Keyboard
- UVa 11988 ------ Broken Keyboard
- UVa-11988 悲剧文本
- UVA 11988 链表
- UVA 11988 链表
- uva 11988 Broken keyboard
- uva
- UVA
- Android NDK 第一个例子 HelloNDK
- 2013国内IT行业薪资对照表【技术岗】
- Highcharts和EXT中panel结合
- GCC编译选项和环境变量
- Excel插件开发
- uva 11988
- Hadoop下join操作的几点优化意见
- 你所不知道的IntentService
- 常见笔试面试题2
- Win7X64下驱动的测试环境搭建.
- 场效应管的判别、检测及使用时的注意事项!
- MapFile和BloomMapFile文件
- 分形(factal)的基本概念
- struts2 DMI 不起作用的原因