-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
土屋の解答 #16
base: master
Are you sure you want to change the base?
土屋の解答 #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
005までレビューいれました
return true; | ||
} else { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここも三項演算子で書けます!
if(n >= 0) { | ||
return n % 2 == 0 ? "正の偶数" : "正の奇数"; | ||
}else{ | ||
return n % 2 == 0 ? "負の偶数" : "負の奇数"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なかなかすっきりしていて良きなロジックですね!
return "合格"; | ||
} else { | ||
return "不合格"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto 三項演算子
return "可"; | ||
} else { | ||
return "不可"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifの条件は整理されてていい感じです!
「ガード節」というキーワードで調べてみてください!
https://qiita.com/kouyan/items/7b8b456b626447a1e24e
} | ||
if (n == 1) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ガードできてる!いいね!
if (n % i == 0) { | ||
|
||
soinsu += " " + i; | ||
n = n / i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
忘れた頃に /=
|
||
while (n > 0) { | ||
nishinsu = (n % 2) + nishinsu; | ||
n = n / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto /=
for (int i = 0; i < list.size(); i++) { | ||
returnArray[i] = list.get(i); | ||
} | ||
return returnArray; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good
|
||
} | ||
|
||
// 並べ替えられた配列を返す | ||
public static int[] sort(int[] n) { | ||
Arrays.sort(n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great
if (str.contains("ge")) { | ||
return true; | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
もしかしてif文すらいらないかもしれない
if (n % 5 == 0 || s.contains("5")) { | ||
return "buzz"; | ||
} | ||
return""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
せっかくPractice016,017で作ったメソッド、使いましょう。
} | ||
|
||
public static boolean isMailAddress(String s) { | ||
|
||
return false; | ||
return s.matches("^[\\w.!#$%&'*+/=?^_`{|}~-]+@[\\w.!#$%&'*+/=?^_`{|}~-]+(\\.com$|\\.co.jp|\\.ne.jp$)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これだと hoge@hoge.neajp
のときにtrueになっちゃいませんか?
.
の扱いに気をつけましょう。
No description provided.