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

{

} } }

} while (o != 0);

} 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();

} break;

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

Sign up to vote on this title
UsefulNot useful