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

 

 


Tema destacado: Curso de javascript por TickTack


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Re: Error al añadir archivos al proyecto en: 5 Abril 2010, 05:44 am
Por algún motivo no logro leer el error que te da. De todos modos, una cosa a comprobar en estos casos es que estás compilando para x86 y no para x86_64, porque, al menos hasta donde yo sé, no existe versión del conector de Access para 64 bits.

Podría darse el caso de que en VS compilaras para 32bits pero generaras el release para 64.
2  Programación / .NET (C#, VB.NET, ASP) / Re: Programas en c#.net (Basico) en: 26 Mayo 2008, 02:06 am
Modificaciones a Autorbuses. Creo que de esta forma queda más claro y didáctico para novatos... aunque no es, ni de lejos, la solución ideal.
Código:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace ElHacker
{
    class Program
    {

        public Program()
        {
            Console.WriteLine(" - AD0 By _Bj0rD_ - ");
            SacarBillete();
        }

        private void SacarBillete()
        {
            double precio = 0;
            int numeroBoletos = ObtenerNumeroBoletos();
            string franja = ObtenerFranjaHoraria();
            precio = numeroBoletos * CalculaPrecio(franja);
            Console.WriteLine("El total por {0} boletos durante el/la {1} es: {2}", numeroBoletos, franja, precio);
            Console.WriteLine("Desea Reiniciar? S/N");
            string s = Console.ReadLine().ToUpper();
            if (s.StartsWith("S"))
                SacarBillete();
        }

        private int CalculaPrecio(string franja)
        {
            if (franja.StartsWith("D"))
                return 50;
            if (franja.StartsWith("T"))
                return 75;
            return 100;
        }

        private string ObtenerFranjaHoraria()
        {
            Console.Write("Su viaje sera de DIA, TARDE o NOCHE?: ");
            string franja = Console.ReadLine().ToUpper();
            if (!franja.StartsWith("D") && !franja.StartsWith("T") && !franja.StartsWith("N"))
            {
                Console.WriteLine("Franja no válida. Inténtelo de nuevo.");
                return ObtenerFranjaHoraria();
            }
            return franja;
        }

        private int ObtenerNumeroBoletos()
        {
            Console.Write("Digite el numero de boletos que adquirira: ");
            int boletos = LeerNumero();
            if (boletos < 1)
            {
                Console.Write("Debe comprar al menos un boleto.");
                return ObtenerNumeroBoletos();
            }
            return boletos;
        }

        private int LeerNumero()
        {
            int retorno = 0;
            try
            {
                retorno = Convert.ToInt32(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("No es un dato correcto. Inténtelo de nuevo: ");
                return LeerNumero();
            }
            return retorno;
        }

        static void Main(string[] args)
        {
            new Program();
        }

    }
}
3  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda sobre ordenacion en C# en: 24 Mayo 2008, 19:19 pm
He usado las palabras de ejemplo directametne en una cadena... simplemente sería leer el fichero y poner el texto en la variable contenidoFichero.
Código:
using System; 
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElHacker
{
    class Program
    {

        class Word
        {
            public string Castellano { get; set; }
            public string Ingles { get; set; }
        }

        private string contenidoFichero = "agua;water\nlibro;book\nguapa;beautiful";

        private List<Word> palabras = new List<Word>();

        public Program()
        {
            ObtenerPalabras();
            GenerarDiccionarioCastellanoIngles();
            GenerarDiccionarioInglesCastellano();
        }

        private void ObtenerPalabras()
        {           
            foreach (var linea in contenidoFichero.Split('\n'))
                palabras.Add(new Word { Castellano = linea.Split(';')[0], Ingles = linea.Split(';')[1] });
        }

        private void GenerarDiccionarioCastellanoIngles()
        {
            var solucion = from palabra in palabras orderby palabra.Castellano ascending select palabra;
            foreach (var palabra in solucion)
                Console.WriteLine(palabra.Castellano +" -> "+ palabra.Ingles);
        }

        private void GenerarDiccionarioInglesCastellano()
        {
            var solucion = from palabra in palabras orderby palabra.Ingles ascending select palabra;
            foreach (var palabra in solucion)
                Console.WriteLine(palabra.Ingles + " -> " + palabra.Castellano);
        }

        static void Main(string[] args)
        {
            new Program();
        }

    }
}
4  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda ; [C#] Algoritmo para saber si un Nº es capicua. en: 23 Mayo 2008, 21:32 pm
Aquí os dejo otra idea... es más o menos lo mismo, pero iterando sólo la mitad de la cadena  ;)

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

namespace ElHacker
{
    class Program
    {

        public Program()
        {
            Console.WriteLine("El numero {0}es capicúa.", (ComprobarCapicua(Console.ReadLine()) ? "" : "no "));
        }

        private bool ComprobarCapicua(string number)
        {
            for (int i = 0; i < number.Length / 2; i++)
                if (number != number[number.Length - 1 - i])
                    return false;
            return true;
        }

        static void Main(string[] args)
        {
            new Program();
        }

    }
}
5  Programación / Ejercicios / Re: Un ejercicio C# en: 23 Mayo 2008, 21:24 pm
Ahí va una posible solución:

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

namespace ElHacker
{
    class Program
    {

        public Program()
        {
            Console.WriteLine("El proceso de Login ha " + ((Login())?"sido un éxito":"fallado"));
        }

        private bool Login()
        {
            int intentos = 0;
            string correctPassword = "ElHacker";
            while (intentos++ < 4)
            {
                Console.Write("Introduzca su contraseña: ");
                if (correctPassword == Console.ReadLine())
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            new Program();
        }

    }
}
6  Programación / Ejercicios / Re: Ejercicios C# en: 23 Mayo 2008, 03:46 am
Ejercicio 4:

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

namespace ElHacker
{
    class Program
    {

        static Func<int, int> TerminoN = numero => Enumerable.Range(0, numero).Aggregate(new { X = 1, Y = 0 }, (p, a) => new { X = p.Y, Y = p.X + p.Y }).Y;

        static void Main(string[] args)
        {
            Console.Write("Introduzca un número: ");
            int number = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < number; i++)
                Console.Write("{0} ", TerminoN(i));
        }

    }
}
7  Programación / Ejercicios / Re: Ejercicios C# en: 23 Mayo 2008, 03:34 am
Para el 3º:

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

namespace ElHacker
{
    class Program
    {     

        static void Main(string[] args)
        {
            Console.Write("Introduzca un año: ");
            int year = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("El año {0}es bisiesto", EsBisiesto(year) ? "" : "NO ");                   
        }

        static Func<int, bool> UltimoAno = x => x % 100==0;
        static Func<int, bool> SecularBisiesto = x => x % 400==0;
        static Func<int, bool> Bisiesto = x => x % 4 == 0;

        static bool EsBisiesto(int ano)
        {
            if (!Bisiesto(ano))
                return false;
            return (UltimoAno(ano) && SecularBisiesto(ano) || !UltimoAno(ano));               
        }

    }
}
8  Programación / Ejercicios / Re: Ejercicios C# en: 23 Mayo 2008, 03:14 am
Ejercicio 2:

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

namespace ElHacker
{
    class Program
    {     

        static void Main(string[] args)
        {
            Console.Write("Introduzca la letra del DNI: ");
            char letra = Convert.ToChar(Console.ReadLine().ToUpper());
            int posicionLetra = "TRWAGMYFPDXBNJZSQVHLCKE".IndexOf(letra);           

            Console.Write("Introduzca cuantos números deséa generar: ");
            int numero = Convert.ToInt32(Console.ReadLine());

            Random rnd = new Random(DateTime.Now.Millisecond);
            for (int i = 0; i < numero;i++)
                Console.Write("{0} ", 23 * rnd.Next(1000000, 3500000) + posicionLetra);
        }

    }
}
9  Programación / Ejercicios / Re: Ejercicios C# en: 23 Mayo 2008, 02:37 am
Ahí va mi solución para el ejercicio 1:

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

namespace ElHacker
{
    class Program
    {

        static Func<int, char> ObtenerLetra = x => "TRWAGMYFPDXBNJZSQVHLCKE"[x % 23];

        static void Main(string[] args)
        {
            Console.Write("Introduzca su DNI: ");
            Console.WriteLine("Su letra es: {0}",ObtenerLetra(Convert.ToInt32(Console.ReadLine())));
        }

    }
}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines