-
Lenguaje
JavaScript
-
Descripción
Se lee un número de máximo tres dígitos (verifique que efectivamente sea de máximo tres dígitos) y se debe determinar si es un número capicúa, es decir, que leído de izquierda a derecha es igual que leído de derecha a izquierda. Por ejemplo: 727, 343, etc.
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
36
37
38
39
40
41
42
43
44
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
36
37
38
39
40
41
42
43
44
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Número capicúa de tres dígitos</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
<html>
<head>
<title>Número capicúa de tres dígitos</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function algoritmo()
{
let un_numero;
un_numero = parseInt (document.formulario1.un_numero.value);
if(un_numero>=10000)
alert('El n\u00FAmero tiene m\u00E1s de 3 d\u00EDgitos.');
if(un_numero<10000&&(un_numero-un_numero%100)/100==un_numero%10)
alert('El n\u00FAmero s\u00ED es capic\u00FAa.');
if(un_numero<10000&&(un_numero-un_numero%100)/100!=un_numero%10)
alert('El n\u00FAmero no es capic\u00FAa.');
}
{
let un_numero;
un_numero = parseInt (document.formulario1.un_numero.value);
if(un_numero>=10000)
alert('El n\u00FAmero tiene m\u00E1s de 3 d\u00EDgitos.');
if(un_numero<10000&&(un_numero-un_numero%100)/100==un_numero%10)
alert('El n\u00FAmero s\u00ED es capic\u00FAa.');
if(un_numero<10000&&(un_numero-un_numero%100)/100!=un_numero%10)
alert('El n\u00FAmero no es capic\u00FAa.');
}
</script>
</head>
<body>
<form name="formulario1">
<table style="text-align: left; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td>
<label for="un_numero">Ingresa el valor de un numero:</label>
</td>
<td>
<input name="un_numero" required="required" step="1" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="button" onclick="algoritmo();" />
<input type="reset" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
</head>
<body>
<form name="formulario1">
<table style="text-align: left; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td>
<label for="un_numero">Ingresa el valor de un numero:</label>
</td>
<td>
<input name="un_numero" required="required" step="1" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="button" onclick="algoritmo();" />
<input type="reset" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>