将ACKII码位于32~126之间的95个字符显示在屏幕上

xiaoxiao2021-02-28  31

将ACKII码位于32~126之间的95个字符显示在屏幕上,为了美观,要求小于100的码值之前填充一个0,没打印8字符后换行

public class ShowAscii { public static void main(String[] args) { String temp = ""; for (int i = 32; i <= 126; i++) { temp = i < 100 ? ("0" + i) : ("" + i); System.out.print(temp + "=" + (char) i + " "); if ((i - 31) % 8 == 0) System.out.print("\n"); } } }
转载请注明原文地址: https://www.6miu.com/read-2630453.html

最新回复(0)