栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 1885 Uncompress

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 1885 Uncompress

#include <iostream>#include <string>#include <list>using namespace std; string str;list<string> table;list<string>::iterator it;int NUM(char x){return x>='0'&&x<='9';}int ALP(char x){return x>='a'&&x<='z'||x>='A'&&x<='Z';}int main(){char c;while((c=getchar())!=-1) str+=c;int i,pos,num;string temp;pos=str.find_last_of("0");str.erase(pos,str.size()-pos);for(i=0;i<str.size();i++){if(NUM(str[i])){num=0;while(NUM(str[i])) num=num*10+str[i++]-'0';i--; pos=0;it=table.begin();while(++pos!=num) it++;temp=*it;printf("%s",it->c_str());table.erase(it);table.push_front(temp);}else if(ALP(str[i])){temp="";while(ALP(str[i])) temp+=str[i++];i--;table.push_front(temp);printf("%s",temp.c_str());}else putchar(str[i]);}return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380105.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号