728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181839
📝 나의 풀이
using System;
public class Solution {
public int solution(int a, int b) {
int answer = 0;
if( a%2 != 0 && b%2!= 0 ){
answer = (a*a) + (b*b);
} else if( a%2 != 0 || b%2!= 0 ){
answer = 2*(a+b);
} else {
answer = Math.Abs(a-b);
}
return answer;
}
}
728x90
'코딩테스트 > [C#] 프로그래머스' 카테고리의 다른 글
[프로그래머스 | C# | Lv.0] 문자열 붙여서 출력하기 (0) | 2023.09.04 |
---|---|
[프로그래머스 | C# | Lv.0] A 강조하기 (0) | 2023.09.03 |
[프로그래머스 | C# | Lv.0] 배열에서 문자열 대소문자 변환하기 (0) | 2023.09.02 |
[프로그래머스 | C# | Lv.0] 5명씩 (0) | 2023.09.02 |
[프로그래머스 | C# | Lv.0] 꼬리 문자열 (1) | 2023.09.01 |