-
Lenguaje
Java
-
Descripción
Muestra la tabla ASCII con equivalencias en decimal, hexadecimal, octal y binario
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
public class Ascii {
public static void main (String[] args) {
Scanner in = new Scanner(System.in);
int i, c;
for (i=0; i<128; i++) {
if (i%23==0) {
if (i!=0) {
System.out.print("Presione una <ENTER> para continuar . . . ");
in.nextLine();
}
System.out.println("ASCII DEC OCTAL HEX BINARIO ASCII DEC OCTAL HEX BINARIO");
}
for (c=i; c<256; c+=128) {
switch (c) {
case '\0': System.out.print("NULL "); break;
case 7 : System.out.print("BEEP "); break;
case '\b': System.out.print("DEL "); break;
case '\t': System.out.print("TAB "); break;
case '\n': System.out.print("CR "); break;
case '\r': System.out.print("LF "); break;
case 26 : System.out.print("SUB "); break;
default : System.out.print((char)c + " ");
}
System.out.printf(" %3d %03o %02X %d%d%d%d%d%d%d%d%s", c, c, c,
(c/128)%2, (c/64)%2, (c/32)%2, (c/16)%2, (c/8)%2, (c/4)%2, (c/2)%2, c%2,
c<128 ? " " : "\n");
}
}
}
}
public class Ascii {
public static void main (String[] args) {
Scanner in = new Scanner(System.in);
int i, c;
for (i=0; i<128; i++) {
if (i%23==0) {
if (i!=0) {
System.out.print("Presione una <ENTER> para continuar . . . ");
in.nextLine();
}
System.out.println("ASCII DEC OCTAL HEX BINARIO ASCII DEC OCTAL HEX BINARIO");
}
for (c=i; c<256; c+=128) {
switch (c) {
case '\0': System.out.print("NULL "); break;
case 7 : System.out.print("BEEP "); break;
case '\b': System.out.print("DEL "); break;
case '\t': System.out.print("TAB "); break;
case '\n': System.out.print("CR "); break;
case '\r': System.out.print("LF "); break;
case 26 : System.out.print("SUB "); break;
default : System.out.print((char)c + " ");
}
System.out.printf(" %3d %03o %02X %d%d%d%d%d%d%d%d%s", c, c, c,
(c/128)%2, (c/64)%2, (c/32)%2, (c/16)%2, (c/8)%2, (c/4)%2, (c/2)%2, c%2,
c<128 ? " " : "\n");
}
}
}
}