Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Programa hecho por Robinet Lucas. El programa indica si, dado una secuncia de palabras, indicar si forman un tautograma o no.
- program tautograma;
- const max=256;
- const marca='*';
- type Tarreglo = array [1..max] of char;
- procedure carga (var sec:Tarreglo); {Utilizacion de esquema R1}
- var
- i:integer;
- begin
- i:=0;
- writeln('Ingrese las palabras');
- repeat
- begin
- i:=i+1;
- read(sec[i]);
- end;
- until sec[i]=marca;
- writeln('Ha completado la carga')
- end;
- procedure muestra(sec:TArreglo);
- var
- i:integer;
- begin
- i:=0;
- repeat
- i:=i+1;
- write(sec[i]);
- until (sec[i]=marca) or (i=max);
- writeln()
- end;
- procedure av_blancos (sec:Tarreglo; var indice:integer); {Utilizacion de esquema R1}
- begin
- // indice:=1; // ACA ESTA EL PROBLEMA
- while (sec[indice]=' ') do
- indice:=indice+1
- end;
- procedure sig_palabra (sec:Tarreglo; var indice:integer); {Utilizacion de esquema R1}
- begin
- writeln('entrando a sig_palabra');
- while (sec[indice]<>marca) and (sec[indice]<>' ') do begin
- writeln('caracter actual: ', sec[indice]);
- indice:=indice+1;
- writeln('el indice esta en ',indice);
- end;
- if(sec[indice]=marca) then writeln('SALIDA DE SIG_PALABR POR CONDICION sec[indice] es la marca');
- if(sec[indice]=' ') then writeln('SALIDA DE SIG_PALABR POR CONDICION sec[indice] es espacio en blanco');
- end;
- var
- x:Tarreglo;
- i:integer;
- primLetra,sigLetra:char;
- igual:boolean;
- begin {Utilizacion de esquema R2}
- carga(x);
- muestra(x);
- if x[1]=marca
- then
- writeln('La secuencia esta vacia')
- else
- if x[1]<>marca
- then
- writeln('llamando av_blancos');
- 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!
- av_blancos(x,i);
- writeln('pasado av_blancos');
- primLetra:=x[i];
- igual:=true;
- while (x[i]<>'*') and (igual=true) do begin
- writeln('siguiente palabra');
- sig_palabra(x,i);
- writeln('llamando av_blancos 2, i=',i,' primLetra=', primLetra); // TODO BIEN HASTA ACA
- av_blancos(x,i);
- 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
- sigLetra:=x[i];
- writeln('sigletra=',sigletra);
- if(sigLetra<>marca) then begin // OBLIGATORIO PORQUE EN EL ULTIMO CICLO SE RECORRE TODA LA ULTIMA PALABRA Y LLEGA A LA MARCA REAL.
- if (primLetra<>sigLetra) then
- igual:=false;
- end
- end;
- if igual=true
- then
- writeln('Se cumple el tautograma')
- else
- writeln('No es tautograma');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement