Skip to content

Instantly share code, notes, and snippets.

@nk4dev
Created July 18, 2023 02:14
Show Gist options
  • Select an option

  • Save nk4dev/0c7ea8cc27faf0b515205fc5a924a5b4 to your computer and use it in GitHub Desktop.

Select an option

Save nk4dev/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());
}
}
@nk4dev
Copy link
Copy Markdown
Author

nk4dev commented Jul 18, 2023

change public

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