728x90
728x90
https://codingbat.com/prob/p182873
CodingBat Java Warmup-1 makes10
Given 2 ints, a and b, return true if one if them is 10 or if their sum is 10.makes10(9, 10) → truemakes10(9, 9) → falsemakes10(1, 9) → trueGo...Save, Compile, Run (ctrl-enter)Show Solution
codingbat.com
= 문제 번역 =
2개의 int a와 b가 주어졌을 때, 하나가 10이거나 합이 10이면 true를 반환합니다.
= 해설 =
< 1 >
public boolean makes10(int a, int b) {
if(a==10||b==10) return true;
if((a+b)==10) return true;
return false;
}
< 2 >
public boolean makes10(int a, int b) {
return ((a==10||b==10)||(a+b)==10);
}
728x90
'코딩테스트 > Coding Bat' 카테고리의 다른 글
[코딩뱃] [자바] Warmup - 1단계 : posNeg 문제 (0) | 2021.09.17 |
---|---|
[코딩뱃] [자바] Warmup - 1단계 : nearHundred 문제 (0) | 2021.09.17 |
[코딩뱃] [자바] Warmup - 1단계 : parrotTrouble 문제 (0) | 2021.09.16 |
[코딩뱃] [자바] Warmup - 1단계 : diff21 문제 (0) | 2021.09.16 |
[코딩뱃] [자바] warmup -1 단계 : sumDouble 문제 (0) | 2021.09.14 |