- 764 名前:デフォルトの名無しさん mailto:sage [2007/11/18(日) 15:26:20 ]
- >>760
ダメ? public class Q760{ public static void main(String args[]){ String s = args[0]; System.out.println("入力された10進数を2進数に変換"); try { String decimal = Integer.toBinaryString(Integer.parseInt(s)); System.out.println("2進数\t" + decimal); } catch (NumberFormatException e) { System.err.println("数字ではありません"); System.exit(0); } System.out.println("\r\n入力された2進数を10進数に変換"); try { int binary = Integer.parseInt(s, 2); System.out.println("10進数\t" + binary); } catch (NumberFormatException e) { System.err.println("2進数表記ではないので10進数に変換しません"); } } }
|

|