yzl_rex

对于算法,我只是一个草民!

zoj 2172 Symmetric Order

#include "iostream"
#include "string"
#include "vector"
using namespace std;

int main()
{
	int num, i, count = 0;
	string temp1, temp2;
	vector<string> v;
	vector<string> v1;
	vector<string> v2;
	vector<string>::iterator it;
	while (cin >> num && num)
	{
		v.clear();
		v1.clear();
		v2.clear();
		for (i = 0; i < num; i++)
		{
			cin >> temp1;
			v.push_back(temp1);
		}
		for (it = v.begin(), i = 0; i < num, it != v.end(); i++, it++)
		{
			if (i % 2 != 0)
			{
				temp2 = (*it);
				v1.push_back(temp2);
			}
			else
			{
				temp2 = (*it);
				v2.push_back(temp2);
			}
		}
		cout << "SET " << ++count << endl;
		for (it = v2.begin(); it != v2.end(); it++)
			cout << (*it) << endl;
		int size = v1.size();
		for (i = size - 1; i >= 0; i--)
			cout << v1[i] << endl;
	}
}

阅读更多
文章标签: iterator include string
个人分类: ZOJ
上一篇zoj 2108 Elevator
下一篇zoj 2208 To and Fro
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭