• Inicio
  • Buscar
  • Ingresar
  • Registrarse

    Evil Dead: The Game el juego multijugador basado en la trilogía Evil DeaD y Ash vs Evil DeaD

    • 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 2431 veces)

    Desconectado SMS

    • { L2 } Nativo Digital
    • **
    • Mensajes: 148
      • Ver Perfil
    [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#
    1.  Console.Write("Cuantos números se va a introducir: ");
    2.             string leerLinea = Console.ReadLine();
    3.             double convertirdouble = double.Parse(leerLinea);
    4.             int x = 0;
    5.             for (int i = 1; i <= convertirdouble;i++)
    6.             {
    7.                 Console.Write("Escribe un número negativo o positivo ");
    8.                 string guardarlinea = Console.ReadLine();
    9.                 double conversor = double.Parse(guardarlinea);
    10.  
    11.                 if(conversor < 0)
    12.                 {
    13.                     x = x + 1;
    14.            
    15.                 }
    16.                  
    17.             }
    18.             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
     

    • SMF | SMF © 2013, Simple Machines
    • XHTML
    • RSS
    • WAP2
    Va un mudo y le dice a un sordo: Hack x Crack usa cookies. Pues eso... Learn more