Advertisement
dito19

Untitled

Feb 26th, 2020
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. public string Mostrar()
  2. {
  3.  
  4. if (EstaVacia())
  5. return "Pila vacia";
  6.  
  7. string salida = "";
  8.  
  9. #region Mostrar de Victor
  10.  
  11. //int maxcar = 0;
  12. //int cmax = max.ToString().Length;
  13. //String[] car = new string[max];
  14.  
  15. //#region Contador caracteres
  16. //for (int j = max - 1; j > -1; j--)
  17. //{
  18. // string pos = Arreglo[j].ToString();
  19. // if (pos.Length > maxcar)
  20. // {
  21. // maxcar = pos.Length;
  22. // }
  23. //}
  24. //#endregion
  25.  
  26. //#region Caracterizador
  27. //for (int k = max - 1; k > -1; k--)
  28. //{
  29. // string pos = Arreglo[k].ToString();
  30. // int carr = pos.Length;
  31. // for (int l = carr; l <= maxcar; l++)
  32. // {
  33. // car[k] += " ";
  34. // }
  35. //}
  36. //#endregion
  37.  
  38. //for (int i = max - 1; i > -1; i--)
  39. //{
  40. // string sp = "";
  41. // string pos = i.ToString();
  42. // int pos1 = pos.Length;
  43. // while (pos1 != cmax)
  44. // {
  45. // sp += " ";
  46. // pos1++;
  47. // }
  48.  
  49. // if (i < top)
  50. // {
  51. // salida += i + " " + sp + "[" + car[i] + Arreglo[i] + "]";
  52. // }
  53. // else
  54. // {
  55. // car[i] += " ";
  56. // salida += i + " " + sp + "[" + car[i] + "]";
  57. // }
  58.  
  59. // if (i == top)
  60. // {
  61. // salida += " T";
  62. // }
  63.  
  64. // if (i != top && Arreglo[i] != 0)
  65. // {
  66. // salida += " C";
  67. // }
  68. // salida += "\n";
  69. //}
  70. #endregion
  71.  
  72. #region Mostrar hecho en clase
  73.  
  74. /*
  75. 3?|?789?|
  76. 2?|?4321?|
  77. 1?|?21?|
  78. 0?|?7?|
  79. */
  80.  
  81. /*
  82. 3?|?*789?|
  83. 2?|?4321?|
  84. 1?|?**21?|
  85. 0?|?***7?|
  86. */
  87.  
  88. int maxCaracteres = MaxLenghtNum();//calculando cantidad de espacios maximos
  89.  
  90. for (int i = this.max - 1; i >= 0; i--)
  91. {
  92. salida += i + " | ";//colocamos indice del renglon
  93.  
  94. // CONDICION TERNARIA
  95. int espacios = i < this.top ? this.arreglo[i].ToString().Length : 0;
  96.  
  97. for (int j = espacios; j < maxCaracteres; j++)
  98. salida += " ";//colocamos espacios antes del valor
  99.  
  100. if (i < this.top)
  101. salida += this.arreglo[i] + " | ";//colocamos el valor y Pipe final
  102. else
  103. salida += " | ";//colocamos el Pipe final
  104.  
  105. // En condición ternaria...
  106. // salida+= i < this.top ? this.arreglo[i] + " | " : " | "
  107.  
  108.  
  109. if (i == this.top)
  110. salida += "T\n";//colocamos T
  111. else
  112. salida += "\n";
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement