본문 바로가기
코딩 테스트/알고리즘

알고리즘 2번 - js, c++, c,c#

by GREEN나무 2024. 11. 11.
728x90

JS

문제

정수 num1, num2가 매개변수 주어집니다. num1과 num2를 곱한 값을 return 하도록 solution 함수를 완성해주세요.


function solution(num1, num2) {
    var answer = 0;
    answer = num1 * num2;
    return answer;
}

 

코드 간략화하기

function solution(num1, num2) {
    return num1 * num2;
}

 

◆ C

int solution(int num1, int num2) {
    return num1 * num2;
}

 


 

  C++

 

int solution(int num1, int num2) {
    return num1 * num2;
}

  C#

public class Solution {
    public int solution(int num1, int num2) {
        return num1 * num2;
    }
}

 

'코딩 테스트 > 알고리즘' 카테고리의 다른 글

알고리즘 4번 - js, c++  (0) 2024.11.12
알고리즘 3번 - js, c++  (0) 2024.11.11
알고리즘 1번  (0) 2024.11.11
알고리즘 40번 - 추가공부  (0) 2024.11.08
알고리즘 39번 - js,c++  (0) 2024.11.07