Skip to content

Instantly share code, notes, and snippets.

@nknighta
Created July 18, 2023 02:14
Show Gist options
  • Save nknighta/0c7ea8cc27faf0b515205fc5a924a5b4 to your computer and use it in GitHub Desktop.
Save nknighta/0c7ea8cc27faf0b515205fc5a924a5b4 to your computer and use it in GitHub Desktop.
//正解
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());
}
}
@nknighta
Copy link
Author

change public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment