Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string Mostrar()
- {
- //if (EstaVacia())
- //{
- // return "Pila Vacia...";
- //}
- string salida =this.top==this.max?"\tMAX=T\n":"\tMAX\n";
- int maxCaracteres = MaxLength();
- for (int i = this.max-1; i >= 0; i--)
- {
- salida += i + " | ";//colocando indice del renglon
- int avance=i<this.top?this.arreglo[i].ToString().Length:0;
- for (int j = avance; j < maxCaracteres; j++)
- salida += " ";
- //esto vvv
- if (i<this.top)
- salida += this.arreglo[i] + " |"; //inserta valor
- else
- salida += " | ";
- //es lo mismo que esto vvv
- //salida+=i<this.top?this.arreglo[i]+" | ": salida+=" | ";
- if (i == this.top)
- salida += " T\n";//colocando Top
- else
- salida += "\n";
- }
- return salida;
- }
- private int MaxLength()
- {
- int maxCaracteres = int.MinValue;
- for (int j = 0; j < this.top; j++)
- if (maxCaracteres < this.arreglo[j].ToString().Length)
- maxCaracteres = this.arreglo[j].ToString().Length;
- return maxCaracteres;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement