Inicio
Buscar
Ingresar
Registrarse
Starfield: el juego que revolucionará el espacio y la tecnología
Hack x Crack - Comunidad de Seguridad informática
»
Programación
»
Otros
»
[c#] Ejercicio bucle for, escribir x numeros y decir cuantos negativos tiene
Imprimir
Páginas: [
1
]
Ir Abajo
Autor
Tema: [c#] Ejercicio bucle for, escribir x numeros y decir cuantos negativos tiene (Leído 3543 veces)
SMS
{ L2 } Nativo Digital
Mensajes: 148
[c#] Ejercicio bucle for, escribir x numeros y decir cuantos negativos tiene
«
en:
Octubre 13, 2014, 04:49:16 pm »
Escriba un programa que pregunte cuántos números se van a introducir, pida esos números y escriba cuántos negativos ha introducido.
Código: C#
Console
.
Write
(
"Cuantos números se va a introducir: "
)
;
string
leerLinea
=
Console
.
ReadLine
(
)
;
double
convertirdouble
=
double
.
Parse
(
leerLinea
)
;
int
x
=
0
;
for
(
int
i
=
1
;
i
<=
convertirdouble
;
i
++
)
{
Console
.
Write
(
"Escribe un número negativo o positivo "
)
;
string
guardarlinea
=
Console
.
ReadLine
(
)
;
double
conversor
=
double
.
Parse
(
guardarlinea
)
;
if
(
conversor
<
0
)
{
x
=
x
+
1
;
}
}
Console
.
WriteLine
(
"Ha escrito"
+
x
+
"números negativos"
)
;
«
Última modificación: Octubre 13, 2014, 05:02:02 pm por SMS
»
En línea
Imprimir
Páginas: [
1
]
Ir Arriba
Hack x Crack - Comunidad de Seguridad informática
»
Programación
»
Otros
»
[c#] Ejercicio bucle for, escribir x numeros y decir cuantos negativos tiene
Va un mudo y le dice a un sordo: Hack x Crack usa cookies. Pues eso...
OK
Learn more