| ||||||||||
| 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 <stdio.h>
#include <string.h>
int main()
{
char back[1001][1001];
char forward[1001][1001];
char command[1000];
char address[1000];
char cur[100];
int i;
int top1=-1;
int top2=-1;
int len;
strcpy(cur,"http://www.acm.org/");
scanf("%s",command);
getchar();
while(1)
{
int flag1=0,flag2=0;
if(command[0]=='V')
{
gets(address);
top2++;
for(i=0;i<strlen(cur);i++)
{
back[top2][i]=cur[i];
}
back[top2][i]='\0';
for(i=0;i<strlen(address);i++)
{
cur[i]=address[i];
}
cur[i]='\0';
top1=-1;
}
else if(command[0]=='B')
{
if(top2==-1)
{
flag1=1;
}
else
{
top1++;
for(i=0;i<strlen(cur);i++)
{
forward[top1][i]=cur[i];
}
forward[top1][i]='\0';
//if(top2!=-1)
{
for(i=0;i<strlen(back[top2]);i++)
{
cur[i]=back[top2][i];
}
cur[i]='\0';
top2--;
}
}
}
else if(command[0]=='F')
{
if(top1==-1)
{
flag2=1;
}
else
{
top2++;
for(i=0;i<strlen(cur);i++)
{
back[top2][i]=cur[i];
}
back[top2][i]='\0';
//if(top1!=-1)
{
for(i=0;i<strlen(forward[top1]);i++)
{
cur[i]=forward[top1][i];
}
cur[i]='\0';
top1--;
}
}
}
else
{
break;
}
if(flag1==1||flag2==1)
{
printf("Ignored\n");
}
else
{
puts(cur);
}
scanf("%s",command);
getchar();
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator