back to dos.txt

来自「北京大学 在线acm在线判题系统 一些题目解答」· 文本 代码 · 共 62 行

TXT
62
字号
/*
   农夫三拳@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 + =
减小字号Ctrl + -
显示快捷键?