Codigo Fuente Pila A Pila

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Codigo Fuente Pila A Pila as PDF for free.

More details

  • Words: 296
  • Pages: 3
using System; using System.Collections; using System.Text; namespace Pila_A_Pila { class Program { static void Main(string[] args) { bool ban = false; Stack pila1 = new Stack(); Stack pila2 = new Stack(); Stack pila3 = new Stack(); Stack pila4 = new Stack(); int n = 0, i, o, d, r; for (i = 1; i <= 9; i++) { Console.Write("Ingresa Numnero"); n = int.Parse(Console.ReadLine()); pila1.Push(n); } do { Console.Clear(); r = 5; Console.SetCursorPosition(8, 3); Console.Write("Pila 1"); foreach (int x in pila1) { Console.SetCursorPosition(10, r); Console.WriteLine("{0}", x); r++; } r = 5; Console.SetCursorPosition(17, 3); Console.Write("Pila 2"); foreach (int x in pila2) { Console.SetCursorPosition(20, r); Console.WriteLine("{0}", x); r++; } r = 5; Console.SetCursorPosition(27, 3); Console.Write("Pila 3"); foreach (int x in pila3) { Console.SetCursorPosition(30, r); Console.WriteLine("{0}", x); r++; } r = 5; Console.SetCursorPosition(37, 3); Console.Write("Pila 4");

foreach (int x in pila4) { Console.SetCursorPosition(40, r); Console.WriteLine("{0}", x); r++; } Console.SetCursorPosition(7, 15); Console.Write("Selecciona Pila Origen "); o = int.Parse(Console.ReadLine()); ban = false; switch (o) { case 1: if (pila1.Count == 0) { Console.SetCursorPosition(15, 20); Console.WriteLine("Pila 1 vacia"); } else { n = (int)pila1.Pop(); ban = true; } break; case 2: if (pila2.Count == 0) { Console.SetCursorPosition(15, 20); Console.WriteLine("Pila 2 vacia"); } else { n = (int)pila2.Pop(); ban = true; } break; case 3: if (pila3.Count == 0) { Console.SetCursorPosition(15, 20); Console.WriteLine("Pila 3 vacia"); } else { n = (int)pila3.Pop(); ban = true; } break; case 4: if (pila4.Count == 0) { Console.SetCursorPosition(15, 20); Console.WriteLine("Pila 4 vacia"); } else

{

n = (int)pila4.Pop(); ban = true;

} break;

} if(ban) { Console.SetCursorPosition(7, 16); Console.Write("Selecciona Pila Destino "); d = int.Parse(Console.ReadLine()); switch (d) { case 1: pila1.Push(n); break; case 2: pila2.Push(n); break; case 3: if(pila3.Count < 5) pila3.Push(n); break; case 4: pila4.Push(n); break; } } Console.Clear();

} }

}

} while (o != 0);

Related Documents

Pila
October 2019 32
Pila
October 2019 36
Pila
June 2020 26
Pila A Mano
November 2019 16
Bu Pila 2.docx
May 2020 17