Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. //Programa hecho por Robinet Lucas. El programa indica si, dado una secuncia de palabras, indicar si forman un tautograma o no.
  2. program tautograma;
  3.  
  4. const max=256;
  5. const marca='*';
  6. type Tarreglo = array [1..max] of char;
  7.  
  8. procedure carga (var sec:Tarreglo); {Utilizacion de esquema R1}
  9. var
  10. i:integer;
  11. begin
  12. i:=0;
  13. writeln('Ingrese las palabras');
  14. repeat
  15. begin
  16. i:=i+1;
  17. read(sec[i]);
  18. end;
  19. until sec[i]=marca;
  20. writeln('Ha completado la carga')
  21. end;
  22.  
  23. procedure muestra(sec:TArreglo);
  24. var
  25. i:integer;
  26. begin
  27. i:=0;
  28. repeat
  29. i:=i+1;
  30. write(sec[i]);
  31. until (sec[i]=marca) or (i=max);
  32. writeln()
  33. end;
  34.  
  35.  
  36. procedure av_blancos (sec:Tarreglo; var indice:integer); {Utilizacion de esquema R1}
  37. begin
  38. // indice:=1; // ACA ESTA EL PROBLEMA
  39. while (sec[indice]=' ') do
  40. indice:=indice+1
  41. end;
  42.  
  43. procedure sig_palabra (sec:Tarreglo; var indice:integer); {Utilizacion de esquema R1}
  44. begin
  45. writeln('entrando a sig_palabra');
  46. while (sec[indice]<>marca) and (sec[indice]<>' ') do begin
  47. writeln('caracter actual: ', sec[indice]);
  48. indice:=indice+1;
  49. writeln('el indice esta en ',indice);
  50. end;
  51. if(sec[indice]=marca) then writeln('SALIDA DE SIG_PALABR POR CONDICION sec[indice] es la marca');
  52. if(sec[indice]=' ') then writeln('SALIDA DE SIG_PALABR POR CONDICION sec[indice] es espacio en blanco');
  53. end;
  54.  
  55. var
  56. x:Tarreglo;
  57. i:integer;
  58. primLetra,sigLetra:char;
  59. igual:boolean;
  60. begin {Utilizacion de esquema R2}
  61. carga(x);
  62. muestra(x);
  63. if x[1]=marca
  64. then
  65. writeln('La secuencia esta vacia')
  66. else
  67. if x[1]<>marca
  68. then
  69. writeln('llamando av_blancos');
  70. i := 1; // ACA ESTABA EL PROBLEMA, VOS ASIGANABAS I:=1 PARA EL PRIMER CARACTER DENTRO DE LA ACCION AV_BLANCOS, PERO AV_BLANCOS SE USA DENTRO DEL CICLO TAMBIEN!
  71. av_blancos(x,i);
  72. writeln('pasado av_blancos');
  73. primLetra:=x[i];
  74. igual:=true;
  75. while (x[i]<>'*') and (igual=true) do begin
  76. writeln('siguiente palabra');
  77. sig_palabra(x,i);
  78. writeln('llamando av_blancos 2, i=',i,' primLetra=', primLetra); // TODO BIEN HASTA ACA
  79. av_blancos(x,i);
  80. writeln('av blancos llamado, i=',i); // ACA ME DI CUENTA Q EN CADA CICLO ASIGNABA A 1 EL INDICE LUEGO DE HABER USADO SIG_PALABRA
  81.  
  82. sigLetra:=x[i];
  83. writeln('sigletra=',sigletra);
  84. if(sigLetra<>marca) then begin // OBLIGATORIO PORQUE EN EL ULTIMO CICLO SE RECORRE TODA LA ULTIMA PALABRA Y LLEGA A LA MARCA REAL.
  85. if (primLetra<>sigLetra) then
  86. igual:=false;
  87. end
  88. end;
  89. if igual=true
  90. then
  91. writeln('Se cumple el tautograma')
  92. else
  93. writeln('No es tautograma');
  94. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement