やるだけ
vector<string> f(string s) { replace(s.begin(), s.end(), '/', ' '); istringstream iss(s); vector<string> v; for (string t; iss >> t; v.push_back(t)) ; return v; } class RelativePath { public: string makeRelative(string path, string curr) { vector<string> v = f(path); vector<string> u = f(curr); int pre = 0; for (int i = 0; i < (int)min(u.size(), v.size()); ++i) { if (u[i] != v[i]) break; pre = i + 1; } string ret; for (int i = pre; i < (int)u.size(); ++i) { ret += "../"; } for (int i = pre; i < (int)v.size(); ++i) { ret += v[i] + "/"; } ret.erase(ret.begin() + ret.size() - 1); return ret; } };