"카타 8급 Count Odd Numbers below n"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
1번째 줄: 1번째 줄:
==C==
==C==
{{카타|8급|C|8}}
{{카타|8급|C|8}}
<source lang='C'>
<syntaxhighlight lang='C'>
long odd_count(long n) {
long odd_count(long n) {
   return n/2;
   return n/2;
}
}
</source>
</syntaxhighlight>


==C++==
==C++==
{{카타|8급|C++|7}}
{{카타|8급|C++|7}}
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
int odd_count(int n){
int odd_count(int n){
   return n/2;
   return n/2;
}
}
</source>
</syntaxhighlight>


==Kotlin==
==Kotlin==
{{카타|8급|Kotlin|3}}
{{카타|8급|Kotlin|3}}
<source lang='kotlin'>
<syntaxhighlight lang='kotlin'>
fun oddCount(n: Int) = n/2
fun oddCount(n: Int) = n/2
</source>
</syntaxhighlight>


==R==
==R==
{{카타|8급|R|2}}
{{카타|8급|R|2}}
<source lang='r'>
<syntaxhighlight lang='r'>
odd_count <- function(n) {
odd_count <- function(n) {
   n %/% 2
   n %/% 2
}
}
</source>
</syntaxhighlight>

2020년 11월 2일 (월) 02:42 기준 최신판

1 C[ | ]

long odd_count(long n) {
  return n/2;
}

2 C++[ | ]

int odd_count(int n){
  return n/2;
}

3 Kotlin[ | ]

fun oddCount(n: Int) = n/2

4 R[ | ]

odd_count <- function(n) {
  n %/% 2
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}