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 NinjaQ at 2005-09-21 13:38:21 on Problem 1363
ft居然是OLE,为什么?
#include <iostream.h>

class stack
{
private:
	int st[1000];
	int top;
public:
	stack() { top = -1; }
	void push(int v) { st[++top] = v; }
	int pop() { return st[top--]; }
	int topValue() { return st[top]; }
	int isEmpty() { return ( top == -1 ); }
	void empty() { top = -1; }
};

void main()
{
	int n, i;
	stack stc;
	int order[100];
	int pt;
	while(1)
	{
		cin >> n;
		if ( n == 0 )
			break;
		while(1)
		{
			pt = 0;
			stc.empty();
			cin >> order[0];
			if ( order[0] == 0 )
				break;
			for ( i = 1; i < n; i++)
				cin >> order[i];
			for ( i = 0; i < n; i++)
			{
				stc.push(i+1); 
				while ( order[pt] == stc.topValue() && stc.isEmpty() == 0 )
				{
					stc.pop();
					pt++;
				}
			}
			if ( stc.isEmpty() != 1 )
				cout << "No" << endl;
			else
				cout << "Yes" << endl;
		}
		cout << endl;
	}
}



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