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

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


  Mostrar Temas
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Agenda de 1000 numeros con ordnacion shell y busqueda lineal en: 1 Junio 2010, 22:09 pm
HOLA LES DEJO ESTE CODIGO Q TRATA DE UNA AGENDA DE 1000 NOMBRES Y MIL NUMEROS Q SE ORDENAN POR SHELL Y BUSQUEDA LINEAL Y COMO PUEDO HACER QUE SEA POR EL METODO DE INSERCION Y POR BUSQUEDA BINARIA YA TENGO EL CODIGO DE INSERCION Y POR BUSQ BINARIA PERO LOS DOS SON POR NUMEROS Y NO ME SALE CON LETRAS.


Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace agenda_de_david
  6. {
  7.    class Program
  8.    {
  9.        static void Main(string[] args)
  10.        {
  11.            string[] vec = new string[1000];
  12.            string[] vecbus = new string[1000];
  13.            int numreg = 0;
  14.            string nom1 = "teofilo 03474534";
  15.            vec[0] = nom1;
  16.            string nom2 = "hugo 4561237895";
  17.            vec[1] = nom2;
  18.            string nom3 = "paco 4578912345";
  19.            vec[2] = nom3;
  20.            string nom4 = "luis 7894561253";
  21.            vec[3] = nom4;
  22.            string nom5 = "poncho 4213678945";
  23.            vec[4] = nom5;
  24.            string nom6 = "alvaro 4521378954";
  25.            vec[5] = nom6;
  26.            string nom7 = "naruto 5516960578";
  27.            vec[6] = nom7;
  28.            string nom8 = "sasuke 4878754021";
  29.            vec[7] = nom8;
  30.            string nom9 = "kakashi 4578922014";
  31.            vec[8] = nom9;
  32.            string nom10 = "haku 4567891230";
  33.            vec[9] = nom10;
  34.            string nom11 = "zabuza 45689123";
  35.            vec[10] = nom11;
  36.            string nom12 = "orochimaru 4561237895";
  37.            vec[11] = nom12;
  38.            string nom13 = "kabuto 4567891001";
  39.            vec[12] = nom13;
  40.            string nom14 = "kisame 4567891234";
  41.            vec[13] = nom14;
  42.            string nom15 = "itachi 4561237895";
  43.            vec[14] = nom15;
  44.            string nom16 = "david 4567891235";
  45.            vec[15] = nom16;
  46.            string nom17 = "pepe 7894562331";
  47.            vec[16] = nom17;
  48.            string nom18 = "jorge 7895554612";
  49.            vec[17] = nom18;
  50.            string nom19 = "carlos 7894561223 ";
  51.            vec[18] = nom19;
  52.            string nom20 = "vanesa 7894561234";
  53.            vec[19] = nom20;
  54.            string nom21 = "ana 4567891235";
  55.            vec[20] = nom21;
  56.            string nom22 = "gerardo 4578923123";
  57.            vec[21] = nom22;
  58.            string nom23 = "mario 4567891230";
  59.            vec[22] = nom23;
  60.            string nom24 = "maria 1234567890";
  61.            vec[23] = nom24;
  62.            string nom25 = "jose 10203078456";
  63.            vec[24] = nom25;
  64.            string nom26 = "eric 7894561230";
  65.            vec[25] = nom26;
  66.            string nom27 = "antonio 1245637821";
  67.            vec[26] = nom27;
  68.            string nom28 = "toño 1235478912";
  69.            vec[27] = nom28;
  70.            string nom29 = "tony 1203456702";
  71.            vec[28] = nom29;
  72.            string nom30 = "everardo 4561237895";
  73.            vec[29] = nom30;
  74.            string nom31 = "sakura 4562137895";
  75.            vec[30] = nom31;
  76.            string nom32 = "ino 4567891236";
  77.            vec[31] = nom32;
  78.            string nom33 = "chougi 4561237894";
  79.            vec[32] = nom33;
  80.            string nom34 = "akamaru 4562137895";
  81.            vec[33] = nom34;
  82.            string nom35 = "shikamaru 1203450123";
  83.            vec[34] = nom35;
  84.            string nom36 = "ioroi 7894521302";
  85.            vec[35] = nom36;
  86.            string nom37 = "fer 4567894561";
  87.            vec[36] = nom37;
  88.            string nom38 = "fernando 1234561289";
  89.            vec[37] = nom38;
  90.            string nom39 = "mosca 1234567889";
  91.            vec[38] = nom39;
  92.            string nom40 = "beto 1201010235";
  93.            vec[39] = nom40;
  94.            string nom41 = "alberto 1234567890";
  95.            vec[40] = nom41;
  96.            string nom42 = "sandra 1234447775";
  97.            vec[41] = nom42;
  98.            string nom43 = "pedro 0213456212";
  99.            vec[42] = nom43;
  100.            string nom44 = "juanita 1212145455";
  101.            vec[43] = nom44;
  102.            string nom45 = "perez 1234444555";
  103.            vec[44] = nom45;
  104.            string nom46 = "gonzalez 1234561232";
  105.            vec[45] = nom46;
  106.            string nom47 = "aniceto 1234562131";
  107.            vec[46] = nom47;
  108.            string nom48 = "victor 1234562210";
  109.            vec[47] = nom48;
  110.            string nom49 = "ignacio 1234562130";
  111.            vec[48] = nom49;
  112.            string nom50 = "fransisco 1234567412";
  113.            vec[49] = nom50;
  114.            string nomb1 = "teofilo";
  115.            vecbus[0] = nomb1;
  116.            string nomb2 = "hugo";
  117.            vecbus[1] = nomb2;
  118.            string nomb3 = "paco";
  119.            vecbus[2] = nomb3;
  120.            string nomb4 = "luis";
  121.            vecbus[3] = nomb4;
  122.            string nomb5 = "poncho";
  123.            vecbus[4] = nomb5;
  124.            string nomb6 = "alvaro";
  125.            vecbus[5] = nomb6;
  126.            string nomb7 = "naruto";
  127.            vecbus[6] = nomb7;
  128.            string nomb8 = "sasuke";
  129.            vecbus[7] = nomb8;
  130.            string nomb9 = "kakashi";
  131.            vecbus[8] = nomb9;
  132.            string nomb10 = "haku";
  133.            vecbus[9] = nomb10;
  134.            string nomb11 = "zabuza";
  135.            vecbus[10] = nomb11;
  136.            string nomb12 = "orochimaru";
  137.            vecbus[11] = nomb12;
  138.            string nomb13 = "kabuto";
  139.            vecbus[12] = nomb13;
  140.            string nomb14 = "kisame";
  141.            vecbus[13] = nomb14;
  142.            string nomb15 = "itachi";
  143.            vecbus[14] = nomb15;
  144.            string nomb16 = "david";
  145.            vecbus[15] = nomb16;
  146.            string nomb17 = "pepe";
  147.            vecbus[16] = nomb17;
  148.            string nomb18 = "jorge";
  149.            vecbus[17] = nomb18;
  150.            string nomb19 = "carlos";
  151.            vecbus[18] = nomb19;
  152.            string nomb20 = "vanesa";
  153.            vecbus[19] = nomb20;
  154.            string nomb21 = "ana";
  155.            vecbus[20] = nomb21;
  156.            string nomb22 = "gerardo";
  157.            vecbus[21] = nomb22;
  158.            string nomb23 = "mario";
  159.            vecbus[22] = nomb23;
  160.            string nomb24 = "maria";
  161.            vecbus[23] = nomb24;
  162.            string nomb25 = "jose";
  163.            vecbus[24] = nomb25;
  164.            string nomb26 = "eric";
  165.            vecbus[25] = nomb26;
  166.            string nomb27 = "antonio";
  167.            vecbus[26] = nomb27;
  168.            string nomb28 = "toño";
  169.            vecbus[27] = nomb28;
  170.            string nomb29 = "tony";
  171.            vecbus[28] = nomb29;
  172.            string nomb30 = "everardo";
  173.            vecbus[29] = nomb30;
  174.            string nomb31 = "sakura";
  175.            vecbus[30] = nomb31;
  176.            string nomb32 = "ino";
  177.            vecbus[31] = nomb32;
  178.            string nomb33 = "chougi";
  179.            vecbus[32] = nomb33;
  180.            string nomb34 = "akamaru";
  181.            vecbus[33] = nomb34;
  182.            string nomb35 = "shikamaru";
  183.            vecbus[34] = nomb35;
  184.            string nomb36 = "ioroi";
  185.            vecbus[35] = nomb36;
  186.            string nomb37 = "fer";
  187.            vecbus[36] = nomb37;
  188.            string nomb38 = "fernando";
  189.            vecbus[37] = nomb38;
  190.            string nomb39 = "mosca";
  191.            vecbus[38] = nomb39;
  192.            string nomb40 = "beto";
  193.            vecbus[39] = nomb40;
  194.            string nomb41 = "alberto";
  195.            vecbus[40] = nomb41;
  196.            string nomb42 = "sandra";
  197.            vecbus[41] = nomb42;
  198.            string nomb43 = "pedro";
  199.            vecbus[42] = nomb43;
  200.            string nomb44 = "juanita";
  201.            vecbus[43] = nomb44;
  202.            string nomb45 = "perez";
  203.            vecbus[44] = nomb45;
  204.            string nomb46 = "gonzalez";
  205.            vecbus[45] = nomb46;
  206.            string nomb47 = "aniceto";
  207.            vecbus[46] = nomb47;
  208.            string nomb48 = "victor";
  209.            vecbus[47] = nomb48;
  210.            string nomb49 = "ignacio";
  211.            vecbus[48] = nomb49;
  212.            string nomb50 = "fransisco";
  213.            vecbus[49] = nomb50;
  214.            Console.Title = "Agenda telefonica";
  215.            Console.ForegroundColor = ConsoleColor.Red;
  216.            Console.WriteLine("                ..:::::::::..          ");
  217.            Console.WriteLine("           ..:::aad8888888baa:::..      ");
  218.            Console.WriteLine("        .::::d:?88888888888?::8b::::.           ");
  219.            Console.WriteLine("      .:::d8888:?88888888??a888888b:::.       ");
  220.            Console.WriteLine("    .:::d8888888a8888888aa8888888888b:::.       ");
  221.            Console.WriteLine("   ::::dP::::::::88888888888::::::::Yb::::       ");
  222.            Console.WriteLine("  ::::dP:::::::::Y888888888P:::::::::Yb::::         ");
  223.            Console.WriteLine(" ::::d8:::::::::::Y8888888P:::::::::::8b::::     DAVID ABRAHAM VEGA   ");
  224.            Console.WriteLine(".::::88::::::::::::Y88888P::::::::::::88::::.    CRISTOPHER MAGAÑA MORENO  ");
  225.            Console.WriteLine(":::::Y8baaaaaaaaaa88P:T:Y88aaaaaaaaaad8P:::::      ");
  226.            Console.WriteLine(":::::::Y88888888888P::|::Y88888888888P:::::::     ");
  227.            Console.WriteLine("::::::::::::::::888:::|:::888::::::::::::::::  ");
  228.            Console.WriteLine("`:::::::::::::::8888888888888b::::::::::::::'       ");
  229.            Console.WriteLine(" :::::::::::::::88888888888888::::::::::::::      ");
  230.            Console.WriteLine("  :::::::::::::d88888888888888:::::::::::::     ");
  231.            Console.WriteLine("   ::::::::::::88::88::88:::88::::::::::::   ");
  232.            Console.WriteLine("    `::::::::::88::88::88:::88::::::::::' ");
  233.            Console.WriteLine("      `::::::::88::88::P::::88::::::::'");
  234.            Console.WriteLine("        `::::::88::88:::::::88::::::");
  235.            Console.WriteLine("           ``:::::::::::::::::::");
  236.            Console.WriteLine("                ``:::::::::''");
  237.            Console.WriteLine();
  238.            Console.WriteLine("PRESS KEY");
  239.            Console.ReadKey();
  240.            goto inicio;
  241.  
  242.  
  243.        inicio:
  244.            try
  245.            {
  246.                int opc = 0;
  247.                Console.Clear();
  248.                do
  249.                {
  250.  
  251.  
  252.                    Console.ForegroundColor = ConsoleColor.Green;
  253.                    Console.WriteLine("Elige una opcion");
  254.                    Console.WriteLine();
  255.                    Console.WriteLine("Hacer un registro..................1");
  256.                    Console.WriteLine();
  257.                    Console.WriteLine("Buscar.............................2");
  258.                    Console.WriteLine();
  259.                    Console.WriteLine("Mostrar registro...................3");
  260.                    Console.WriteLine();
  261.                    Console.WriteLine("Salir..............................4");
  262.                    Console.WriteLine();
  263.                    Console.Write("que deseas hacer: ");
  264.                    opc = int.Parse(Console.ReadLine());
  265.  
  266.  
  267.  
  268.                } while (opc < 1 || opc > 4);
  269.                Console.Clear();
  270.  
  271.  
  272.                switch (opc)
  273.                {
  274.                    case 1:
  275.                        Console.ForegroundColor = ConsoleColor.Magenta;
  276.                        string nom;
  277.                        Console.WriteLine("Cuantos registros vas a hacer??");
  278.                        numreg = int.Parse(Console.ReadLine());
  279.  
  280.                        for (int inj = 50; inj < numreg + 50; inj++)
  281.                        {
  282.                            Console.Clear();
  283.                            Console.WriteLine("Cual es el nombre??");
  284.                            nom = Console.ReadLine();
  285.                            Console.WriteLine("Cual es tu numero??");
  286.                            string nu = Console.ReadLine();
  287.                            vecbus[inj] = nom;
  288.                            string nn = nom + " " + nu;
  289.                            vec[inj] = nn;
  290.                        }
  291.                        //Descomponer el nombre en la primera letra
  292.  
  293.                        char[] veclec = new char[numreg + 50];
  294.                        int[] guardar = new int[numreg + 50];
  295.                        for (int ifo = 0; ifo < numreg + 50; ifo++)
  296.                        {
  297.  
  298.  
  299.                            char[] dato = vecbus[ifo].ToCharArray();
  300.                            //Vec almacena la primera letra
  301.                            veclec[ifo] = dato[0];
  302.                            if (veclec[ifo] == 'a')
  303.                                guardar[ifo] = 1;
  304.                            if (veclec[ifo] == 'b')
  305.                                guardar[ifo] = 2;
  306.                            if (veclec[ifo] == 'c')
  307.                                guardar[ifo] = 3;
  308.                            if (veclec[ifo] == 'd')
  309.                                guardar[ifo] = 4;
  310.                            if (veclec[ifo] == 'e')
  311.                                guardar[ifo] = 5;
  312.                            if (veclec[ifo] == 'f')
  313.                                guardar[ifo] = 6;
  314.                            if (veclec[ifo] == 'g')
  315.                                guardar[ifo] = 7;
  316.                            if (veclec[ifo] == 'h')
  317.                                guardar[ifo] = 8;
  318.                            if (veclec[ifo] == 'i')
  319.                                guardar[ifo] = 9;
  320.                            if (veclec[ifo] == 'j')
  321.                                guardar[ifo] = 10;
  322.                            if (veclec[ifo] == 'k')
  323.                                guardar[ifo] = 11;
  324.                            if (veclec[ifo] == 'l')
  325.                                guardar[ifo] = 12;
  326.                            if (veclec[ifo] == 'm')
  327.                                guardar[ifo] = 13;
  328.                            if (veclec[ifo] == 'n')
  329.                                guardar[ifo] = 14;
  330.                            if (veclec[ifo] == 'ñ')
  331.                                guardar[ifo] = 15;
  332.                            if (veclec[ifo] == 'o')
  333.                                guardar[ifo] = 16;
  334.                            if (veclec[ifo] == 'p')
  335.                                guardar[ifo] = 17;
  336.                            if (veclec[ifo] == 'q')
  337.                                guardar[ifo] = 18;
  338.                            if (veclec[ifo] == 'r')
  339.                                guardar[ifo] = 19;
  340.                            if (veclec[ifo] == 's')
  341.                                guardar[ifo] = 20;
  342.                            if (veclec[ifo] == 't')
  343.                                guardar[ifo] = 21;
  344.                            if (veclec[ifo] == 'u')
  345.                                guardar[ifo] = 22;
  346.                            if (veclec[ifo] == 'v')
  347.                                guardar[ifo] = 23;
  348.                            if (veclec[ifo] == 'w')
  349.                                guardar[ifo] = 24;
  350.                            if (veclec[ifo] == 'x')
  351.                                guardar[ifo] = 25;
  352.                            if (veclec[ifo] == 'y')
  353.                                guardar[ifo] = 26;
  354.                            if (veclec[ifo] == 'z')
  355.                                guardar[ifo] = 27;
  356.                        }
  357.  
  358.                        //shell
  359.  
  360.                        //int salto, k, j, aux;
  361.                        //string auxtex, auxnombus;
  362.                        //int ord;
  363.                        //salto = numreg + 50;
  364.                        //while (salto > 1)
  365.                        //{
  366.                        //    salto = salto / 2;
  367.                        //    do
  368.                        //    {
  369.                        //        ord = 1;
  370.                        //        for (j = 0; j <= (numreg + 50) - 1 - salto; j = j + salto)
  371.                        //        {
  372.                        //            k = j + salto;
  373.                        //            if (guardar[j] > guardar[k])
  374.                        //            {
  375.                        //                aux = guardar[j];
  376.                        //                auxtex = vec[j];
  377.                        //                auxnombus = vecbus[j];
  378.                        //                guardar[j] = guardar[k];
  379.                        //                vec[j] = vec[k];
  380.                        //                vecbus[j] = vecbus[k];
  381.                        //                guardar[k] = aux;
  382.                        //                vec[k] = auxtex;
  383.                        //                vecbus[k] = auxnombus;
  384.                        //                ord = 0;
  385.                        //            }
  386.                        //        }
  387.  
  388.                        //    }
  389.                        //    while (ord == 0);
  390.                        //}
  391.                        goto inicio;
  392.  
  393.                    case 2:
  394.                        Console.ForegroundColor = ConsoleColor.White;
  395.                        Console.WriteLine("Cual es el nombre que deseas buskar ??");
  396.                        string bus = Console.ReadLine();
  397.                        for (int ibus = 0; ibus < 1000; ibus++)
  398.                        {
  399.                            if (vecbus[ibus] == bus)
  400.                                Console.WriteLine("Se encontro " + vec[ibus] + " en la posicion {0}", ibus + 1);
  401.                        }
  402.                        Console.ReadKey();
  403.                        goto inicio;
  404.                    case 3:
  405.                        Console.ForegroundColor = ConsoleColor.Green;
  406.                        for (int inm = 0; inm < numreg + 50; inm++)
  407.                        {
  408.                            if (vec[inm] != " ")
  409.                                Console.WriteLine(vec[inm]);
  410.                        }
  411.                        Console.ReadKey();
  412.                        goto inicio;
  413.  
  414.                    case 4:
  415.                        break;
  416.  
  417.                }
  418.            }
  419.            catch
  420.            {
  421.                Console.Clear();
  422.                goto inicio;
  423.            }
  424.        }
  425.    }
  426. }
  427.  
2  Foros Generales / Dudas Generales / agenda de 1000 numeros en: 1 Junio 2010, 21:55 pm
hola les dejo este codigo ya lo hice con el metodo shell y busqueda lineal pero como lo puedo hacer q sea el metodo de insercion y busqueda binaria.

Código
  1.  


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

namespace agenda_de_david
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] vec = new string[1000];
            string[] vecbus = new string[1000];
            int numreg = 0;
            string nom1 = "teofilo 03474534";
            vec[0] = nom1;
            string nom2 = "hugo 4561237895";
            vec[1] = nom2;
            string nom3 = "paco 4578912345";
            vec[2] = nom3;
            string nom4 = "luis 7894561253";
            vec[3] = nom4;
            string nom5 = "poncho 4213678945";
            vec[4] = nom5;
            string nom6 = "alvaro 4521378954";
            vec[5] = nom6;
            string nom7 = "naruto 5516960578";
            vec[6] = nom7;
            string nom8 = "sasuke 4878754021";
            vec[7] = nom8;
            string nom9 = "kakashi 4578922014";
            vec[8] = nom9;
            string nom10 = "haku 4567891230";
            vec[9] = nom10;
            string nom11 = "zabuza 45689123";
            vec[10] = nom11;
            string nom12 = "orochimaru 4561237895";
            vec[11] = nom12;
            string nom13 = "kabuto 4567891001";
            vec[12] = nom13;
            string nom14 = "kisame 4567891234";
            vec[13] = nom14;
            string nom15 = "itachi 4561237895";
            vec[14] = nom15;
            string nom16 = "david 4567891235";
            vec[15] = nom16;
            string nom17 = "pepe 7894562331";
            vec[16] = nom17;
            string nom18 = "jorge 7895554612";
            vec[17] = nom18;
            string nom19 = "carlos 7894561223 ";
            vec[18] = nom19;
            string nom20 = "vanesa 7894561234";
            vec[19] = nom20;
            string nom21 = "ana 4567891235";
            vec[20] = nom21;
            string nom22 = "gerardo 4578923123";
            vec[21] = nom22;
            string nom23 = "mario 4567891230";
            vec[22] = nom23;
            string nom24 = "maria 1234567890";
            vec[23] = nom24;
            string nom25 = "jose 10203078456";
            vec[24] = nom25;
            string nom26 = "eric 7894561230";
            vec[25] = nom26;
            string nom27 = "antonio 1245637821";
            vec[26] = nom27;
            string nom28 = "toño 1235478912";
            vec[27] = nom28;
            string nom29 = "tony 1203456702";
            vec[28] = nom29;
            string nom30 = "everardo 4561237895";
            vec[29] = nom30;
            string nom31 = "sakura 4562137895";
            vec[30] = nom31;
            string nom32 = "ino 4567891236";
            vec[31] = nom32;
            string nom33 = "chougi 4561237894";
            vec[32] = nom33;
            string nom34 = "akamaru 4562137895";
            vec[33] = nom34;
            string nom35 = "shikamaru 1203450123";
            vec[34] = nom35;
            string nom36 = "ioroi 7894521302";
            vec[35] = nom36;
            string nom37 = "fer 4567894561";
            vec[36] = nom37;
            string nom38 = "fernando 1234561289";
            vec[37] = nom38;
            string nom39 = "mosca 1234567889";
            vec[38] = nom39;
            string nom40 = "beto 1201010235";
            vec[39] = nom40;
            string nom41 = "alberto 1234567890";
            vec[40] = nom41;
            string nom42 = "sandra 1234447775";
            vec[41] = nom42;
            string nom43 = "pedro 0213456212";
            vec[42] = nom43;
            string nom44 = "juanita 1212145455";
            vec[43] = nom44;
            string nom45 = "perez 1234444555";
            vec[44] = nom45;
            string nom46 = "gonzalez 1234561232";
            vec[45] = nom46;
            string nom47 = "aniceto 1234562131";
            vec[46] = nom47;
            string nom48 = "victor 1234562210";
            vec[47] = nom48;
            string nom49 = "ignacio 1234562130";
            vec[48] = nom49;
            string nom50 = "fransisco 1234567412";
            vec[49] = nom50;
            string nomb1 = "teofilo";
            vecbus[0] = nomb1;
            string nomb2 = "hugo";
            vecbus[1] = nomb2;
            string nomb3 = "paco";
            vecbus[2] = nomb3;
            string nomb4 = "luis";
            vecbus[3] = nomb4;
            string nomb5 = "poncho";
            vecbus[4] = nomb5;
            string nomb6 = "alvaro";
            vecbus[5] = nomb6;
            string nomb7 = "naruto";
            vecbus[6] = nomb7;
            string nomb8 = "sasuke";
            vecbus[7] = nomb8;
            string nomb9 = "kakashi";
            vecbus[8] = nomb9;
            string nomb10 = "haku";
            vecbus[9] = nomb10;
            string nomb11 = "zabuza";
            vecbus[10] = nomb11;
            string nomb12 = "orochimaru";
            vecbus[11] = nomb12;
            string nomb13 = "kabuto";
            vecbus[12] = nomb13;
            string nomb14 = "kisame";
            vecbus[13] = nomb14;
            string nomb15 = "itachi";
            vecbus[14] = nomb15;
            string nomb16 = "david";
            vecbus[15] = nomb16;
            string nomb17 = "pepe";
            vecbus[16] = nomb17;
            string nomb18 = "jorge";
            vecbus[17] = nomb18;
            string nomb19 = "carlos";
            vecbus[18] = nomb19;
            string nomb20 = "vanesa";
            vecbus[19] = nomb20;
            string nomb21 = "ana";
            vecbus[20] = nomb21;
            string nomb22 = "gerardo";
            vecbus[21] = nomb22;
            string nomb23 = "mario";
            vecbus[22] = nomb23;
            string nomb24 = "maria";
            vecbus[23] = nomb24;
            string nomb25 = "jose";
            vecbus[24] = nomb25;
            string nomb26 = "eric";
            vecbus[25] = nomb26;
            string nomb27 = "antonio";
            vecbus[26] = nomb27;
            string nomb28 = "toño";
            vecbus[27] = nomb28;
            string nomb29 = "tony";
            vecbus[28] = nomb29;
            string nomb30 = "everardo";
            vecbus[29] = nomb30;
            string nomb31 = "sakura";
            vecbus[30] = nomb31;
            string nomb32 = "ino";
            vecbus[31] = nomb32;
            string nomb33 = "chougi";
            vecbus[32] = nomb33;
            string nomb34 = "akamaru";
            vecbus[33] = nomb34;
            string nomb35 = "shikamaru";
            vecbus[34] = nomb35;
            string nomb36 = "ioroi";
            vecbus[35] = nomb36;
            string nomb37 = "fer";
            vecbus[36] = nomb37;
            string nomb38 = "fernando";
            vecbus[37] = nomb38;
            string nomb39 = "mosca";
            vecbus[38] = nomb39;
            string nomb40 = "beto";
            vecbus[39] = nomb40;
            string nomb41 = "alberto";
            vecbus[40] = nomb41;
            string nomb42 = "sandra";
            vecbus[41] = nomb42;
            string nomb43 = "pedro";
            vecbus[42] = nomb43;
            string nomb44 = "juanita";
            vecbus[43] = nomb44;
            string nomb45 = "perez";
            vecbus[44] = nomb45;
            string nomb46 = "gonzalez";
            vecbus[45] = nomb46;
            string nomb47 = "aniceto";
            vecbus[46] = nomb47;
            string nomb48 = "victor";
            vecbus[47] = nomb48;
            string nomb49 = "ignacio";
            vecbus[48] = nomb49;
            string nomb50 = "fransisco";
            vecbus[49] = nomb50;
            Console.Title = "Agenda telefonica";
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("                ..:::::::::..          ");
            Console.WriteLine("           ..:::aad8888888baa:::..      ");
            Console.WriteLine("        .::::d:?88888888888?::8b::::.           ");
            Console.WriteLine("      .:::d8888:?88888888??a888888b:::.       ");
            Console.WriteLine("    .:::d8888888a8888888aa8888888888b:::.       ");
            Console.WriteLine("   ::::dP::::::::88888888888::::::::Yb::::       ");
            Console.WriteLine("  ::::dP:::::::::Y888888888P:::::::::Yb::::         ");
            Console.WriteLine(" ::::d8:::::::::::Y8888888P:::::::::::8b::::     DAVID ABRAHAM VEGA   ");
            Console.WriteLine(".::::88::::::::::::Y88888P::::::::::::88::::.    CRISTOPHER MAGAÑA MORENO  ");
            Console.WriteLine(":::::Y8baaaaaaaaaa88P:T:Y88aaaaaaaaaad8P:::::      ");
            Console.WriteLine(":::::::Y88888888888P::|::Y88888888888P:::::::     ");
            Console.WriteLine("::::::::::::::::888:::|:::888::::::::::::::::  ");
            Console.WriteLine("`:::::::::::::::8888888888888b::::::::::::::'       ");
            Console.WriteLine(" :::::::::::::::88888888888888::::::::::::::      ");
            Console.WriteLine("  :::::::::::::d88888888888888:::::::::::::     ");
            Console.WriteLine("   ::::::::::::88::88::88:::88::::::::::::   ");
            Console.WriteLine("    `::::::::::88::88::88:::88::::::::::' ");
            Console.WriteLine("      `::::::::88::88::P::::88::::::::'");
            Console.WriteLine("        `::::::88::88:::::::88::::::");
            Console.WriteLine("           ``:::::::::::::::::::");
            Console.WriteLine("                ``:::::::::''");
            Console.WriteLine();
            Console.WriteLine("PRESS KEY");
            Console.ReadKey();
            goto inicio;


        inicio:
            try
            {
                int opc = 0;
                Console.Clear();
                do
                {


                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Elige una opcion");
                    Console.WriteLine();
                    Console.WriteLine("Hacer un registro..................1");
                    Console.WriteLine();
                    Console.WriteLine("Buscar.............................2");
                    Console.WriteLine();
                    Console.WriteLine("Mostrar registro...................3");
                    Console.WriteLine();
                    Console.WriteLine("Salir..............................4");
                    Console.WriteLine();
                    Console.Write("que deseas hacer: ");
                    opc = int.Parse(Console.ReadLine());



                } while (opc < 1 || opc > 4);
                Console.Clear();


                switch (opc)
                {
                    case 1:
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        string nom;
                        Console.WriteLine("Cuantos registros vas a hacer??");
                        numreg = int.Parse(Console.ReadLine());

                        for (int inj = 50; inj < numreg + 50; inj++)
                        {
                            Console.Clear();
                            Console.WriteLine("Cual es el nombre??");
                            nom = Console.ReadLine();
                            Console.WriteLine("Cual es tu numero??");
                            string nu = Console.ReadLine();
                            vecbus[inj] = nom;
                            string nn = nom + " " + nu;
                            vec[inj] = nn;
                        }
                        //Descomponer el nombre en la primera letra

                        char[] veclec = new char[numreg + 50];
                        int[] guardar = new int[numreg + 50];
                        for (int ifo = 0; ifo < numreg + 50; ifo++)
                        {


                            char[] dato = vecbus[ifo].ToCharArray();
                            //Vec almacena la primera letra
                            veclec[ifo] = dato[0];
                            if (veclec[ifo] == 'a')
                                guardar[ifo] = 1;
                            if (veclec[ifo] == 'b')
                                guardar[ifo] = 2;
                            if (veclec[ifo] == 'c')
                                guardar[ifo] = 3;
                            if (veclec[ifo] == 'd')
                                guardar[ifo] = 4;
                            if (veclec[ifo] == 'e')
                                guardar[ifo] = 5;
                            if (veclec[ifo] == 'f')
                                guardar[ifo] = 6;
                            if (veclec[ifo] == 'g')
                                guardar[ifo] = 7;
                            if (veclec[ifo] == 'h')
                                guardar[ifo] = 8;
                            if (veclec[ifo] == 'i')
                                guardar[ifo] = 9;
                            if (veclec[ifo] == 'j')
                                guardar[ifo] = 10;
                            if (veclec[ifo] == 'k')
                                guardar[ifo] = 11;
                            if (veclec[ifo] == 'l')
                                guardar[ifo] = 12;
                            if (veclec[ifo] == 'm')
                                guardar[ifo] = 13;
                            if (veclec[ifo] == 'n')
                                guardar[ifo] = 14;
                            if (veclec[ifo] == 'ñ')
                                guardar[ifo] = 15;
                            if (veclec[ifo] == 'o')
                                guardar[ifo] = 16;
                            if (veclec[ifo] == 'p')
                                guardar[ifo] = 17;
                            if (veclec[ifo] == 'q')
                                guardar[ifo] = 18;
                            if (veclec[ifo] == 'r')
                                guardar[ifo] = 19;
                            if (veclec[ifo] == 's')
                                guardar[ifo] = 20;
                            if (veclec[ifo] == 't')
                                guardar[ifo] = 21;
                            if (veclec[ifo] == 'u')
                                guardar[ifo] = 22;
                            if (veclec[ifo] == 'v')
                                guardar[ifo] = 23;
                            if (veclec[ifo] == 'w')
                                guardar[ifo] = 24;
                            if (veclec[ifo] == 'x')
                                guardar[ifo] = 25;
                            if (veclec[ifo] == 'y')
                                guardar[ifo] = 26;
                            if (veclec[ifo] == 'z')
                                guardar[ifo] = 27;
                        }

                        //shell

                        //int salto, k, j, aux;
                        //string auxtex, auxnombus;
                        //int ord;
                        //salto = numreg + 50;
                        //while (salto > 1)
                        //{
                        //    salto = salto / 2;
                        //    do
                        //    {
                        //        ord = 1;
                        //        for (j = 0; j <= (numreg + 50) - 1 - salto; j = j + salto)
                        //        {
                        //            k = j + salto;
                        //            if (guardar[j] > guardar[k])
                        //            {
                        //                aux = guardar[j];
                        //                auxtex = vec[j];
                        //                auxnombus = vecbus[j];
                        //                guardar[j] = guardar[k];
                        //                vec[j] = vec[k];
                        //                vecbus[j] = vecbus[k];
                        //                guardar[k] = aux;
                        //                vec[k] = auxtex;
                        //                vecbus[k] = auxnombus;
                        //                ord = 0;
                        //            }
                        //        }

                        //    }
                        //    while (ord == 0);
                        //}
                        goto inicio;

                    case 2:
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Cual es el nombre que deseas buskar ??");
                        string bus = Console.ReadLine();
                        for (int ibus = 0; ibus < 1000; ibus++)
                        {
                            if (vecbus[ibus] == bus)
                                Console.WriteLine("Se encontro " + vec[ibus] + " en la posicion {0}", ibus + 1);
                        }
                        Console.ReadKey();
                        goto inicio;
                    case 3:
                        Console.ForegroundColor = ConsoleColor.Green;
                        for (int inm = 0; inm < numreg + 50; inm++)
                        {
                            if (vec[inm] != " ")
                                Console.WriteLine(vec[inm]);
                        }
                        Console.ReadKey();
                        goto inicio;

                    case 4:
                        break;

                }
            }
            catch
            {
                Console.Clear();
                goto inicio;
            }
        }
    }
}
3  Programación / Ejercicios / componente timer en: 16 Abril 2010, 20:06 pm
como puedo hacer uso del componente timer  :¬¬
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines