domingo, 24 de noviembre de 2013

MENU CON VECTOR Y ORDENAMIENTO

MENU CON LLENADO DE UN VECTOR Y SU ORDENAMIENTO DE MENOR A MAYOR

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text; 

namespace VECTORES

{

    class Program

    {

        static void Main(string[] args)

        {

            int a, b, c;

            double [] d,e,f;

             string aux;

             d = new double[5];

             e = new double[5];

             f = new double[5];

             do

             {

                 Console.Clear();

                 Console.SetCursorPosition(19, 3);

                 Console.Write("M  E  N  U");

                 Console.SetCursorPosition(10, 5);

                 Console.Write("1.- LLENAR VECTOR");

   Console.SetCursorPosition(10, 6);

                 Console.Write("2.- ORDENAMIENTO DEL VECTOR ANTERIOR DE MENOR A MAYOR");

                 Console.SetCursorPosition(10, 7);

                 Console.Write("3.- SALIR  ");

                 Console.SetCursorPosition(10, 9);

                 Console.Write("QUE OPCION DESEAS  ");

                 aux = Console.ReadLine();

                 a = int.Parse(aux);

                 Console.Clear();

                 switch (a)

                 {

                     case 1:

                         {

                            

                             Console.SetCursorPosition(10, 6);

                             Console.Write("LLENADO DEL VECTOR");

                             Console.SetCursorPosition(10, 8);

                             Console.Write("**********");

                             Console.SetCursorPosition(10, 9);

                             Console.Write("*        *");

                             Console.SetCursorPosition(10, 10);

                             Console.Write("**********");

                             Console.SetCursorPosition(10, 11);

                             Console.Write("*        *");

                             Console.SetCursorPosition(10, 12);

                             Console.Write("**********");

                             Console.SetCursorPosition(10, 13);

                             Console.Write("*        *");

                             Console.SetCursorPosition(10, 14);

                             Console.Write("**********");

                             Console.SetCursorPosition(10, 15);

                             Console.Write("*        *");

                             Console.SetCursorPosition(10, 16);

                             Console.Write("**********");

                             Console.SetCursorPosition(10, 17);

                             Console.Write("*        *");

                             Console.SetCursorPosition(10, 18);

                             Console.Write("**********");

                             b = 9;

                             for (c = 0; c < 5; c++)

                             {

                                 Console.SetCursorPosition(3, b);

                                 Console.Write("d[ " + c + " ]");

                                 Console.SetCursorPosition(12, b);

                                 aux = Console.ReadLine();

                                 d[c] = int.Parse(aux);

                                

                                 b = b + 2;

                             }

                             Console.ReadKey();

                             break;

                         }

                     

                     case 2:

                          Console.SetCursorPosition(10, 6);

                              Console.Write("VECTOR D");

                              Console.SetCursorPosition(10, 8);

                              Console.Write("**********");

                              Console.SetCursorPosition(10, 9);

                              Console.Write("*        *");

                              Console.SetCursorPosition(10, 10);

                              Console.Write("**********");

                              Console.SetCursorPosition(10, 11);

                              Console.Write("*        *");

                              Console.SetCursorPosition(10, 12);

                              Console.Write("**********");

                              Console.SetCursorPosition(10, 13);

                              Console.Write("*        *");

                              Console.SetCursorPosition(10, 14);

                              Console.Write("**********");

                              Console.SetCursorPosition(10, 15);

                              Console.Write("*        *");

                              Console.SetCursorPosition(10, 16);

                              Console.Write("**********");

                              Console.SetCursorPosition(10, 17);

                              Console.Write("*        *");

                              Console.SetCursorPosition(10, 18);

                              Console.Write("**********");

 

                              Console.SetCursorPosition(37, 6);

                              Console.Write("VECTOR E ORDENADO");

                              Console.SetCursorPosition(40, 8);

                              Console.Write("**********");

                              Console.SetCursorPosition(40, 9);

                              Console.Write("*        *");

                              Console.SetCursorPosition(40, 10);

                              Console.Write("**********");

                              Console.SetCursorPosition(40, 11);

                              Console.Write("*        *");

                              Console.SetCursorPosition(40, 12);

                              Console.Write("**********");

                              Console.SetCursorPosition(40, 13);

                              Console.Write("*        *");

                              Console.SetCursorPosition(40, 14);

                              Console.Write("**********");

                              Console.SetCursorPosition(40, 15);

                              Console.Write("*        *");

                              Console.SetCursorPosition(40, 16);

                              Console.Write("**********");

                              Console.SetCursorPosition(40, 17);

                              Console.Write("*        *");

                              Console.SetCursorPosition(40, 18);

                              Console.Write("**********");

                          b = 9;

                             for (c = 0; c < 5; c++)

                             {

                                 Console.SetCursorPosition(3, b);

                                 Console.Write("d[ " + c + " ]");

                                 Console.SetCursorPosition(12, b);

                                 Console.Write(d[c]);

                                 b = b + 2;

                             }

                             for (c = 0; c < 5; c++)

                             {

                                 e[c] = d[c];

                             }

                             double x;

                             for (a = 0; a < 4; a++)

                             {

                                 for (b = a + 1; b < 5; b++)

                                 {

                                     if (e[a] > e[b])

                                     {

                                         x = e[a];

                                         e[a] = e[b];

                                         e[b] = x;

                                     }

                                 }

                             }

                         b = 9;

                              for (c = 0; c < 5; c++)

                              {

                                 Console.SetCursorPosition(30, b);

                                  Console.Write("e[ " + c + " ]");

                                  Console.SetCursorPosition(43, b);

                                  Console.Write(e[c]);

                                  b = b + 2;

                              }

                              Console.ReadKey();

                          break;

                     case 3:

                          break;

                     default:

                         Console.SetCursorPosition(23, 8);

                                  Console.Write("ENTIENDE SOLO SON 4 OPCIONES");

                                  Console.ReadKey();

                          break;

 

                 }

 

 

             }

             while (a != 3);

 

        }

    }

}

No hay comentarios:

Publicar un comentario