Resolución de problemas y algoritmos Dra. Jessica Andrea Carballido jac@cs.uns.edu.ar Dpto. de Ciencias e Ingeniería de la Computación UNIVERSIDAD NACIONAL DEL SUR
Problema: Dada una secuencia S de caracteres (finalizada en punto), mostrar las vocales en el orden que aparecen, y luego las consonantes invertidas. Entre las vocales y las consonantes debe mostrar un asterisco. Mostrar vocales y consonantes de S Caso Base: Si S es un punto, mostrar un *. Caso Recursivo: Si S tiene más de un elemento; si el 1er elemento de S es una vocal, mostrarla y luego Mostrar vocales y consonantes de S’, si el 1er elemento de S es una consonante, Mostrar vocales y consonantes de S’ y luego mostrar la consonante, en otro caso Mostrar vocales y consonantes de S’. Donde S’ es S sin su primer elemento.
procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else if esVocal(ch) then begin write(ch); mostrarVyC; end if esLetra(ch) // es consonante ya que es letra y no es vocal then begin end;
E s t a ? . E s t a ? . Buffer ch program InversionParcial; procedure mostrarVyC; … begin writeln(‘Ingrese una secuencia finalizando en .’); mostrarVyC; end. Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch E s t a ? . E s t a ? . Buffer
E s t a ? . E s t a ? . Buffer ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; Ingrese una secuencia finalizando en . ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; E s t a ? . E s t a ? . Buffer
E s t a ? . E s t a ? . Buffer ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; E s t a ? . E s t a ? . Buffer
E s t a ? . E s t a ? . Buffer ch ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch E s t a ? . E s t a ? . Buffer
E s t a ? . E s t a ? . Buffer ch ch ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch E s t a ? . E s t a ? . Buffer
E s t a ? . E s t a ? . Buffer ch ch ch ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch E s t a ? . E s t a ? . Buffer
E s t a ? . Buffer ch ch ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch ch ch E s t a ? . Buffer
E s t a ? . Buffer ch ch ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch E s t a ? . Buffer
E s t a ? . Buffer ch ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch E s t a ? . Buffer
E s t a ? . Buffer ch ch ch Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; E s t a ? . Buffer
E s t a ? . Buffer ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; Ingrese una secuencia finalizando en . ch ch procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; E s t a ? . Buffer
E s t a ? . Buffer ch program InversionParcial; procedure mostrarVyC; … begin writeln(‘Ingrese una secuencia finalizando en .’); mostrarVyC; end. Ingrese una secuencia finalizando en . procedure mostrarVyC; var ch: char; begin read(ch); if ch='.‘ then write(' * ') else begin if esVocal(ch) then begin write(ch); mostrarVyC; end else if esLetra(ch) then begin mostrarVyC; write(ch); end else mostrarVyC; end; ch E s t a ? . Buffer