"카타 8급 Remove String Spaces"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-분류:PHP +))
3번째 줄: 3번째 줄:
{{카타 8급-34}}
{{카타 8급-34}}
|}
|}
==C==
[[분류: 카타 8급 C]]
<source lang='C'>
</source>


==C++==
==C++==

2019년 2월 5일 (화) 01:22 판

1 개요

카타 8급 C
# 🔗 문제 풀이

틀:카타 8급-34

2 C

3 C++

std::string no_space(std::string x)
{
  x.erase(std::remove(x.begin(), x.end(), ' '), x.end());
  return x;
}
std::string no_space(std::string x)
{    
    std::string temp="";
    for(int i = 0;i<x.size();i++){
      if(x[i]!=' ')
        temp+=x[i];
    }
    return temp;
}

4 PHP

function no_space(string $s): string {
  return str_replace(' ','',$s);
}
function no_space(string $s): string {
  return preg_replace("/\s/", "", $s);
}

5 같이 보기

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