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

我的也是测试没问题,但就是wrong Answer,各位有劳帮小弟一把。这里先谢过了!!!!!!

Posted by shengye_205 at 2007-05-05 15:23:59 on Problem 1028
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
int const StackMaxSize=100;
struct Stack
{
	char stack[StackMaxSize][80];
	int top;
};
void Push(Stack & S,const char item[],int n)
{
	S.top++;
	strcpy(S.stack[S.top],item);
}
char* Pop(Stack & S,char a[],int n)
{
	a=S.stack[S.top];
	S.top--;
	return a;
}
Stack Sb,Sf;

void main()
{
	Sb.top=Sf.top=-1;
	char *a=new char [80];
	strcpy(a,"http://www.acm.org/ ");
	char p[80]="";
	cin.getline(p,80);
	while(strcmp(p,"QUIT")!=0)
	{
		if(p[0]=='V')
		{
		    while(Sf.top!=-1)
				Sf.top--;
			
			Push(Sb,a,80);
		
			strcpy(a,(p+6));
			for(int i=0;i<(int)strlen(a);i++)
				cout<<a[i];
			cout<<endl;
		}
		else if(p[0]=='B')
		{
	
			if(Sb.top==-1)
			
				cout<<"Ignored"<<endl;
			
			else
			{
				Push(Sf,a,80);
				a=Pop(Sb,a,80);
				for(int i=0;i<(int)strlen(a);i++)
					cout<<a[i];
				cout<<endl;
			}
		}
		else if(p[0]=='F')
		{
			if(Sf.top==-1)
				cout<<"Ignored"<<endl;
			else{
				Push(Sb,a,80);
				a=Pop(Sf,a,80);
				for(int i=0;i<(int)strlen(a);i++)
					cout<<a[i];
				cout<<endl;
			}
		}
		cin.getline(p,80);
	}
}

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