Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

权且娱乐吧,用手指和眼睛想出来的代码……

Posted by Web_Board at 2009-02-08 20:55:52 on Problem 1028
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator