Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
指针操作#include"iostream" #include"string" using namespace std; struct Web{ string s; int back; int ford; }w[105]; string c; int main() { int i,j,order; w[0].s="http://www.acm.org/"; w[0].back=-1; w[0].ford=-1; i=0;j=0;order=0; while(cin>>c) { if(c[0]=='Q')break; else if(c[0]=='V') { i++; cin>>w[i].s; w[i].back=order; w[i].ford=-1; cout<<w[i].s<<endl; order=i; } else if(c[0]=='B') { j=w[order].back; if(j+1) { cout<<w[j].s<<endl; w[j].ford=order; order=j; } else cout<<"Ignored"<<endl; } else { if(w[order].ford+1) { cout<<w[w[order].ford].s<<endl; w[w[order].ford].back=order; order=w[order].ford; } else cout<<"Ignored"<<endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator