How to reverse all letters and punctuation in each individual word?
4 ビュー (過去 30 日間)
古いコメントを表示
Larissa Monjaraz
2021 年 3 月 13 日
コメント済み: Larissa Monjaraz
2021 年 3 月 13 日
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 件のコメント
採用された回答
Walter Roberson
2021 年 3 月 13 日
Hint:
phrase = 'help me!'
strjoin(cellfun(@sort, regexp(phrase, ' ', 'split'), 'uniform', 0), ' ')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!