카타 8급 Abbreviate a Two Word Name

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:48 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 C++[ | ]

std::string abbrevName(std::string name)
{
  std::string ret = "";
  ret += toupper(name[0]);
  ret += '.';
  ret += toupper(name[name.find(' ')+1]);
  return ret;
}
std::string abbrevName(std::string name)
{
  std::string ret;
  ret.push_back(toupper(name[0]));
  ret.push_back('.');
  ret.push_back(toupper(name[name.find(' ') + 1] ));
  return ret;
}
std::string abbrevName(std::string name)
{
  std::string ret = "";
  ret += toupper(name[0]);
  ret += '.';
  ret += toupper(name[name.find_last_of(' ')+1]);
  return ret;
}
std::string abbrevName(std::string name)
{
  std::string ret;
  ret += toupper(name[0]);
  ret += '.';
  for(int i=1; i<name.length(); i++)
    if(name[i] == ' ') return ret += toupper(name[i+1]);
  return ret;
}

2 PHP[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}