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 wrp at 2009-11-22 19:18:14 on Problem 1028
#include<iostream>
#include<string>
using namespace std;

class stack
{private:
    string array[20];
	int size;
	int top;
public:
	stack(int n)
	{top=0;
	 size=n;
	}

	~stack()
	{}

	bool push(string &ch)
	{
	 if(top==size)  
		return 0;
	 array[top++]=ch;
	 return 1;
	}

	bool pop(string tt,string &ch)
	{  if(top==1)   	
	{
		cout<<"Ignored"<<endl;
	    return 1;
	}
	 if(tt=="BACK")
		 cout<<array[top-2]<<endl;
	 else cout<<array[top-1]<<endl;  
	 ch=array[--top];
	 return 0;
    }
};

int main()
{stack A(20),B(20);
 string sign="http://www.acm.org/";
A.push(sign);
 while(1)
 {cin>>sign;
 if(sign=="QUIT")
	 return 0;
 string key;
 if(sign=="VISIT")
 {
	 string Webname;
	 cin>>Webname;
	 cout<<Webname<<endl;
	 A.push(Webname);
 }
 else if(sign=="BACK")
 {   
	 if(!A.pop(sign,key))
	 B.push(key);
 }
 else 
 {
	 B.pop(sign,key);
	 A.push(key);
 }
 }
 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