Created
July 18, 2023 02:14
-
-
Save nknighta/0c7ea8cc27faf0b515205fc5a924a5b4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//正解 | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
// 最初の#を追加する | |
StringBuilder sb = new StringBuilder("#"); | |
for (int i = 0; i < 3; i++ ) { | |
// 10新数ベースの色入力 (R G B) | |
int a = sc.nextInt(); | |
// intをHEX変換 | |
String hex = Integer.toHexString(a); | |
// 0パディング | |
if (hex.length() == 1) { | |
sb.append("0"); | |
} | |
// 結果をBuilderに追加 | |
sb.append(hex); | |
} | |
// 出力をtoUpperCaseで大文字に変換 | |
System.out.println(sb.toString().toUpperCase()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
change public