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!