其他分享
首页 > 其他分享> > Rails POJ - 1363

Rails POJ - 1363

作者:互联网

Rails POJ - 1363
链接

代码:

#include<stack>
#include<iostream>
using namespace std;
int main()
{
	int n;
	int num[1005];
	while (cin >> n&&n)
	{
		while (1)
		{
			stack<int> a;
			cin >> num[0];
			if (num[0] == 0)
				break;
			for (int i = 1; i < n; i++)
				cin >> num[i];
			int t(0);
			for (int i = 1; i <= n; i++)
			{
				a.push(i);
				while (a.empty() != 1 && a.top() == num[t])
				{
					a.pop();
					t++;
				}
			}
			if (t == n)
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}
		cout << endl;
	}
	return 0;
}

标签:int,cin,Rails,while,num,POJ,1363
来源: https://blog.csdn.net/weixin_45045689/article/details/90069169