Problem 171. Reverse the Words (not letters) of a String
Solution Stats
Problem Comments
-
1 Comment
Eagle wangzhaowu
on 18 Apr 2020
s2='';
s1=[' ',s1];
a=findstr(s1,' ');
a=[a length(s1)];
for i=length(a):-1:2
s2= strcat(s2,s1(a(i-1):a(i)));
end
s2(:,1)=[];
Problem Recent Solvers330
Suggested Problems
-
Which values occur exactly three times?
4377 Solvers
-
4172 Solvers
-
822 Solvers
-
Sum of first n positive integers
483 Solvers
-
Check that number is whole number
2314 Solvers
More from this Author56
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!