Ajedrez y armario

This commit is contained in:
PC de clase committed 2026-10-08 12:19:11 +02:00
1 parent f8c5b228df
commit 6c4a36dfef
2 files changed
+50

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
// Convertir la posición del tablero de ajedrez en números
// a notación algebraica. Ex: 5 2 -> d 2
void main() {
Scanner sc = new Scanner(System.in);
int h = 0, v = 0;
do {
System.out.println("Introduce la casilla del tablero con numeros: ");
h = sc.nextInt();
v = sc.nextInt();
if (h == 0 && v == 0) break;
if (h < 1 || v < 1 || h > 8 || h > 8) {
System.out.println("ERROR: Casillas inválidas");
return;
}
char letra = (char) ((8 - h) + (int) ('a'));
System.out.printf("%c %d\n", letra, v);
} while (true);
}
+32
View File
@@ -0,0 +1,32 @@
// Determinar si tengo más ropa de verano o invierno (o ambos)
// V I I I I V. -> Invierno | V V V V I. -> Verano | VVIIAA -> Empate
void main() {
Scanner sc = new Scanner(System.in);
int i = 0;
char c = '0';
while (true) {
c = sc.next().charAt(0);
switch (c) {
case 'V':
i++;
break;
case 'I':
i--;
break;
case '.':
if (i < 0)
System.out.println("Invierno");
else if (i > 0)
System.out.println("Verano");
else
System.out.println("Empate");
i = 0;
break;
case 'A':
break;
default:
System.out.println("Carácter invalido");
}
}
}