Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public string Mostrar()
  2. {
  3. //if (EstaVacia())
  4. //{
  5. // return "Pila Vacia...";
  6. //}
  7. string salida =this.top==this.max?"\tMAX=T\n":"\tMAX\n";
  8. int maxCaracteres = MaxLength();
  9. for (int i = this.max-1; i >= 0; i--)
  10. {
  11. salida += i + " | ";//colocando indice del renglon
  12. int avance=i<this.top?this.arreglo[i].ToString().Length:0;
  13.  
  14. for (int j = avance; j < maxCaracteres; j++)
  15. salida += " ";
  16. //esto vvv
  17. if (i<this.top)
  18. salida += this.arreglo[i] + " |"; //inserta valor
  19.  
  20. else
  21. salida += " | ";
  22. //es lo mismo que esto vvv
  23. //salida+=i<this.top?this.arreglo[i]+" | ": salida+=" | ";
  24.  
  25. if (i == this.top)
  26. salida += " T\n";//colocando Top
  27. else
  28. salida += "\n";
  29.  
  30. }
  31. return salida;
  32. }
  33. private int MaxLength()
  34. {
  35. int maxCaracteres = int.MinValue;
  36. for (int j = 0; j < this.top; j++)
  37. if (maxCaracteres < this.arreglo[j].ToString().Length)
  38. maxCaracteres = this.arreglo[j].ToString().Length;
  39.  
  40. return maxCaracteres;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement