⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 back to dos.txt

📁 北京大学 在线acm在线判题系统 一些题目解答
💻 TXT
字号:
/*
   农夫三拳@seu
   drizzlecrj.gmail.com
   2007-03-02
*/
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int n;
string root;
string result;

int main()
{
	string cmd;
	int i;
	int t = 1;
	while(cin >> result)
	{
		cin >> n;
		cin.ignore();
		root = result.substr(0, result.find('\\') + 1);
		while(n--)
		{
			getline(cin, cmd);
			istringstream is(cmd.substr(2));
			is >> cmd;
			if(cmd == "..")
			{
				if(result != root)
				{
					i = result.length() - 2;
					while(i >= 0 && result[i] != '\\')
						i--;
					result = result.substr(0, i + 1);
				}
			}
			else if(cmd == "\\")
			{
				result = root;
			}
			else if(cmd[0] == '\\')
			{
				result = root.substr(0, root.find('\\')) + cmd;
			}
			else
			{
				result += cmd;

			}
			if(result[ result.size() - 1 ] != '\\')
					result += '\\';
		}
		cout << "Case " << t++ << ":" << endl;
		cout << result << endl << endl;
	}

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -