SRM405 DIV1 250
日課消化。Unixの相対パスの記述問題。特に難しいところはありません。
というか問題文が長すぎていて読んでない…。テストケースだけで問題を類推しているので、間違いがあるかも。
makeRelative
class RelativePath { public: string makeRelative(string path, string currentDir) { int i=0; string result = ""; while(path[i] == currentDir[i] && currentDir[i] != '\0'){ i++; } if(currentDir[i] != '\0'){ result += "../"; } int j=i; while(currentDir[j] != '\0'){ if(currentDir[j] == '/') result += "../"; j++; } if(path[i] == '/') i++; result += path.substr(i); return result; } };