elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


  Mostrar Mensajes
Páginas: [1]
1  Programación / Ejercicios / Re: Ejercicio c#[Nivel intermedio] en: 20 Octubre 2017, 21:43 pm
si me hizo pensar pero ahí esta la respuesta  :xD


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
           
            string animal;
            string pert = "a";
            int i;
            Console.WriteLine("bienvenido a petstx");
            Console.WriteLine("¿que animal quiere comprar?");
            animal = Console.ReadLine();

            List<string> animales = new List<string>();
            animales.Add("perro");
            animales.Add("gato");
            animales.Add("pez");
            animales.Add("hamster");
            animales.Add("conejo");
            animales.Add("canario");
            animales.Add("tortuga");
            animales.Add("raton");
            animales.Add("armadillo");
            animales.Add("loro");

            for ( i = 0; i < animales.Count; i++)
            {
               
                if (animal == animales)
                {
                    pert = "el animal si se encuentra";
                    i = animales.Count;
                }
                else
                {
                    pert = "el animal no se encuentra";
                }
   
            }

            Console.WriteLine(pert);
            Console.ReadKey();
        }
    }
}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines