"카타 8급 Multiply"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 11개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==Bash==
==Bash==
[[분류:카타 8급 Bash]]
<syntaxhighlight lang='bash'>
<source lang='bash'>
#!/bin/bash -e
#!/bin/bash -e
a=$1
a=$1
b=$2
b=$2
expr $a \* $b
expr $a \* $b
</source>
</syntaxhighlight>
<source lang='bash'>
<syntaxhighlight lang='bash'>
#!/bin/bash -e
#!/bin/bash -e
a=$1
a=$1
b=$2
b=$2
echo $((a*b))
echo $((a*b))
</source>
</syntaxhighlight>


==C==
==C==
[[분류:카타 8급 C]]
{{카타|8급|C|1}}
<source lang='c'>
<syntaxhighlight lang='c'>
int multiply(int a, int b) {
int multiply(int a, int b) {
   return a * b;
   return a * b;
}
}
</source>
</syntaxhighlight>


==C++==
==C++==
[[분류:카타 8급 C++]]
{{카타|8급|C++|1}}
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
int multiply(int a, int b)
int multiply(int a, int b)
{
{
     return a * b;
     return a * b;
}
}
</source>
</syntaxhighlight>


==Go==
==Go==
[[분류:카타 8급 Go]]
[[분류:카타 8급 Go]]
<source lang='go'>
<syntaxhighlight lang='go'>
package multiply
package multiply


39번째 줄: 38번째 줄:
   return a * b
   return a * b
}
}
</source>
</syntaxhighlight>
 
==JavaScript==
{{카타|8급|JavaScript|1}}
<syntaxhighlight lang='JavaScript'>
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
</syntaxhighlight>
 
==Kotlin==
{{카타|8급|Kotlin|1}}
<syntaxhighlight lang='kotlin'>
fun multiply(x: Double, y: Double) = x * y
</syntaxhighlight>
<syntaxhighlight lang='kotlin'>
fun multiply(x: Double, y: Double): Double = x * y
</syntaxhighlight>
<syntaxhighlight lang='kotlin'>
fun multiply(x: Double, y: Double): Double {
    return x * y
}
</syntaxhighlight>


==PHP==
==PHP==
[[분류:카타 8급 PHP]]
{{카타|8급|PHP|1}}
<source lang='php'>
<syntaxhighlight lang='php'>
function multiply($a, $b) {
function multiply($a, $b) {
   return $a * $b;
   return $a * $b;
}
}
</source>
</syntaxhighlight>
 
==R==
{{카타|8급|R|1}}
<syntaxhighlight lang='r'>
mul <- function(a, b) {
  a * b
}
</syntaxhighlight>
<syntaxhighlight lang='r'>
mul <- function(a, b) {
  return(a * b);
}
</syntaxhighlight>
<syntaxhighlight lang='r'>
mul <- `*`
</syntaxhighlight>
<syntaxhighlight lang='r'>
mul = `*`
</syntaxhighlight>

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

1 Bash[ | ]

#!/bin/bash -e
a=$1
b=$2
expr $a \* $b
#!/bin/bash -e
a=$1
b=$2
echo $((a*b))

2 C[ | ]

int multiply(int a, int b) {
  return a * b;
}

3 C++[ | ]

int multiply(int a, int b)
{
    return a * b;
}

4 Go[ | ]

package multiply

func Multiply(a, b int) int {
  return a * b
}

5 JavaScript[ | ]

6 Kotlin[ | ]

fun multiply(x: Double, y: Double) = x * y
fun multiply(x: Double, y: Double): Double = x * y
fun multiply(x: Double, y: Double): Double {
    return x * y
}

7 PHP[ | ]

function multiply($a, $b) {
  return $a * $b;
}

8 R[ | ]

mul <- function(a, b) {
  a * b
}
mul <- function(a, b) {
  return(a * b);
}
mul <- `*`
mul = `*`