| ||||||||||
| 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<malloc.h>
char * buf[2][101];
int sp0,sp1;
int main()
{
char com[10];
buf[0][0]=(char *)malloc(sizeof(char)*71);
sprintf(buf[0][0],"%s","http://www.acm.org/");
sp0=sp1=1;
while(scanf("%s",com)){//sp0-1为当前页
switch(com[0]){
case 'V':
buf[0][sp0]=(char *)malloc(sizeof(char)*71);
scanf("%s",buf[0][sp0]);
while(sp1>1)
free(buf[1][--sp1]);
printf("%s\n",buf[0][sp0++]);
break;
case 'B':
if(sp0<=1){
printf("Ignored\n");
break;
}
buf[1][sp1++]=buf[0][--sp0];
printf("%s\n",buf[0][sp0-1]);
break;
case 'F':
if(sp1<=1){
printf("Ignored\n");
break;
}
buf[0][sp0++]=buf[1][--sp1];
printf("%s\n",buf[1][sp1]);
break;
case 'Q':
return 0;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator