miércoles, 30 de noviembre de 2011

EJEMPLO DE VECTORES

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace VEC

{

    class Program

    {

        static void Main(string[] args)

        {

            int[] a;

            int b, c;

            string aux;

            a = new int[5];

            Console.SetCursorPosition(20, 4);

            Console.WriteLine("LLENADO DEL VECTOR A");

            Console.SetCursorPosition(30, 5);

            Console.WriteLine("**********");

            Console.SetCursorPosition(30, 6);

            Console.WriteLine("*        *");

            Console.SetCursorPosition(30, 7);

            Console.WriteLine("**********");

            Console.SetCursorPosition(30, 8);

            Console.WriteLine("*        *");

            Console.SetCursorPosition(30, 9);

            Console.WriteLine("**********");

            Console.SetCursorPosition(30, 10);

            Console.WriteLine("*        *");

            Console.SetCursorPosition(30, 11);

            Console.WriteLine("**********");

            Console.SetCursorPosition(30, 12);

            Console.WriteLine("*        *");

            Console.SetCursorPosition(30, 13);

            Console.WriteLine("**********");

            Console.SetCursorPosition(30, 14);

            Console.WriteLine("*        *");

            Console.SetCursorPosition(30, 15);

            Console.WriteLine("**********");

            c = 6;

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

            {

                Console.SetCursorPosition(22, c);

                Console.Write("a[ " + b + " ]");

                Console.SetCursorPosition(33, c);

                aux = Console.ReadLine();

                a[b] = int.Parse(aux);

                c = c + 2;

            }

            Console.ReadKey();

        }

    }

}

SWITCH

SUMATORIA DE QUEBRADOS Y RAICES CON SWITCH

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace sw1

{

  class Program

   {

      static void Main(string[] args)

       {

          int a;

          double sum, b, c, d;

          string aux;

          do

           {

             Console.Clear();

             Console.SetCursorPosition(12, 6);

Console.WriteLine("1.- DA EL VALOR DE N PARA 1/8+2/8+...+N/8 ");

Console.SetCursorPosition(12, 7);

Console.WriteLine("2.- DA EL VALOR DE N PARA 1^.5+2^.33+...+N^N+1");

Console.SetCursorPosition(12, 8);

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

Console.SetCursorPosition(8, 9);

Console.Write("QUE OPCION DESEAS ");

aux = Console.ReadLine();

a = int.Parse(aux);

Console.Clear();

switch (a)

{

   case 1:

     {

Console.SetCursorPosition(15, 10);

Console.Write("DAME EL VALOR DE N ");

aux=Console.ReadLine();

b = int.Parse(aux);

sum = 0;

for (c = 1; c <= b; c++)

  {

sum = sum + c / 8;

  }

Console.SetCursorPosition(15, 12);

Console.Write("EL VALOR DE LA SUMA ES " + sum);

Console.ReadKey();

break;

     }

               case 2:

    {

Console.SetCursorPosition(15, 10);

Console.WriteLine("DAME EL VALOR DE N");

aux=Console.ReadLine();

b = int.Parse(aux);

sum = 0; d = 1;

for (c = 1; c <= b; c++)

  {

sum = sum + Math.Pow(c, 1 / (d + 1));

}

                 Console.SetCursorPosition(15, 12);

   Console.WriteLine("EL VALOR DE LA SUMA ES " + sum);

   Console.ReadKey();

   break;

  }

case 3:

  {

break;

  }

default:

  {

Console.SetCursorPosition(15, 10);

Console.WriteLine("SOLO SON 3 OPCIONES");

Console.ReadKey();

break;

   }

    }



    }

    while (a != 3);

   }

  }

 }