Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string Mostrar()
- {
- if (EstaVacia())
- return "Pila vacia";
- string salida = "";
- #region Mostrar de Victor
- //int maxcar = 0;
- //int cmax = max.ToString().Length;
- //String[] car = new string[max];
- //#region Contador caracteres
- //for (int j = max - 1; j > -1; j--)
- //{
- // string pos = Arreglo[j].ToString();
- // if (pos.Length > maxcar)
- // {
- // maxcar = pos.Length;
- // }
- //}
- //#endregion
- //#region Caracterizador
- //for (int k = max - 1; k > -1; k--)
- //{
- // string pos = Arreglo[k].ToString();
- // int carr = pos.Length;
- // for (int l = carr; l <= maxcar; l++)
- // {
- // car[k] += " ";
- // }
- //}
- //#endregion
- //for (int i = max - 1; i > -1; i--)
- //{
- // string sp = "";
- // string pos = i.ToString();
- // int pos1 = pos.Length;
- // while (pos1 != cmax)
- // {
- // sp += " ";
- // pos1++;
- // }
- // if (i < top)
- // {
- // salida += i + " " + sp + "[" + car[i] + Arreglo[i] + "]";
- // }
- // else
- // {
- // car[i] += " ";
- // salida += i + " " + sp + "[" + car[i] + "]";
- // }
- // if (i == top)
- // {
- // salida += " T";
- // }
- // if (i != top && Arreglo[i] != 0)
- // {
- // salida += " C";
- // }
- // salida += "\n";
- //}
- #endregion
- #region Mostrar hecho en clase
- /*
- 3?|?789?|
- 2?|?4321?|
- 1?|?21?|
- 0?|?7?|
- */
- /*
- 3?|?*789?|
- 2?|?4321?|
- 1?|?**21?|
- 0?|?***7?|
- */
- int maxCaracteres = MaxLenghtNum();//calculando cantidad de espacios maximos
- for (int i = this.max - 1; i >= 0; i--)
- {
- salida += i + " | ";//colocamos indice del renglon
- // CONDICION TERNARIA
- int espacios = i < this.top ? this.arreglo[i].ToString().Length : 0;
- for (int j = espacios; j < maxCaracteres; j++)
- salida += " ";//colocamos espacios antes del valor
- if (i < this.top)
- salida += this.arreglo[i] + " | ";//colocamos el valor y Pipe final
- else
- salida += " | ";//colocamos el Pipe final
- // En condición ternaria...
- // salida+= i < this.top ? this.arreglo[i] + " | " : " | "
- if (i == this.top)
- salida += "T\n";//colocamos T
- else
- salida += "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement