Created
May 1, 2020 06:24
-
-
Save DongguemYoo/d77adb21a5c2eacd4c2406bb46ceebc6 to your computer and use it in GitHub Desktop.
코딩테스트 연습 두 정수 사이의 합
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public long solution(int a, int b) { | |
long answer = 0; | |
(var minValue, var maxValue) = a > b ? (b, a) : (a, b); //3항 연산자 특이하게 쓰는법 | |
for (int num = minValue; num <= maxValue; num++) | |
answer += num; | |
return answer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment