| ||||||||||
| 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 | |||||||||
奇怪的问题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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator