How to reverse all letters and punctuation in each individual word?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Larissa Monjaraz
el 13 de Mzo. de 2021
Comentada: Larissa Monjaraz
el 13 de Mzo. de 2021
Just to clarify this is a HW assignment so some help (no matter how small) woudl be nice. So the assignment is to reverse an individual word in a phrase.
Example: Help me! ---> pleH !em
This is what I have so far:
clc,clear;
phrase = input('Enter any phase: ','s');
phrase = phrase(end:-1:1);
disp(phrase)
Thanks for the help everyone!
0 comentarios
Respuesta aceptada
Walter Roberson
el 13 de Mzo. de 2021
Hint:
phrase = 'help me!'
strjoin(cellfun(@sort, regexp(phrase, ' ', 'split'), 'uniform', 0), ' ')
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!