프로그래머스 C# 숫자 비교하기(파이썬, 자바)
2023. 3. 31. 00:37ㆍC# 알고리즘 코딩(프로그래머스)
using System;
public class Solution {
public int solution(int num1, int num2) {
if (num1 < 0 || num1 > 10000 || num2 < 0 || num2 > 10000) {
throw new Exception("invalid param");
}
if(num1 == num2)
{
return 1;
}
else return -1;
}
}
////
파이썬
def solution(num1, num2):
return 1 if num1==num2 else -1
자바
////////////
class Solution {
public int solution(int num1, int num2) {
int answer = (num1 == num2) ? 1 : -1;
return answer;
}
}
'C# 알고리즘 코딩(프로그래머스)' 카테고리의 다른 글
프로그래머스 C# 중복된 숫자 개수(foreach 파이썬, 자바) (0) | 2023.04.02 |
---|---|
프로그래머스 C# 각도기(3항 연산자, 파이썬, 자바) (0) | 2023.04.02 |
프로그래머스 C# 나이 출력(파이썬) (0) | 2023.03.30 |
프로그래머스 C# 두 수의 차, 두 수의 곱, 나머지 구하기 (0) | 2023.03.28 |
백준 A+B(자바, C#) (0) | 2023.02.24 |