카타 8급 Sort and Star


C++

std::string twoSort(std::vector<std::string> s)
{
  std::string res = *min_element(s.begin(), s.end());
  for(int i=1; i<res.length(); i+=4) res.insert(i, "***");
  return res;
}
std::string twoSort(std::vector<std::string> s)
{
  std::string m = *(min_element(s.begin(), s.end()));
  std::string res;
  for (int i = 0; i<m.length(); i++) {
    res += m[i];
    if(i != m.length()-1) res += "***";
  }
  return res;
}
std::string twoSort(std::vector<std::string> s)
{
  std::string m = *(min_element(s.begin(), s.end()));
  std::string res= m.substr(0,1);
  for(int i=1; i<m.length();i++) {
    res += "***" + m.substr(i,1);
  }
  return res;
}

PHP