How can I create a function for palindrome ? Anyone can help me with.
1 次查看(过去 30 天)
显示 更早的评论
Write a testPalindromes() function that accepts a string then returns true if the string reads the same backwards as forwards and false otherwise. (Do NOT use loops) Thanks In Advance
1 个评论
Jan
2016-11-28
As in the other discussions about palindromes in this forum (note: searching the internet will reveal solutions already...), the handling of spaces and upper/lower-case must be defined.
采纳的回答
KSSV
2016-11-28
str = 'civic' ;
% str = 'cool' ;
if strcmpi(str,fliplr(str))
fprintf('yes %s is a palindrome \n',str)
else
fprintf('no %s is not a palindrome \n',str)
end
3 个评论
KSSV
2016-11-28
@Jan Simon, mostly I don't answer HW questions. I found this to be simple, I don't think this to be a HW problem.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!