How can I create a function for palindrome ? Anyone can help me with.

1 回表示 (過去 30 日間)
Abdulrehman Khan
Abdulrehman Khan 2016 年 11 月 28 日
コメント済み: Abdulrehman Khan 2016 年 11 月 28 日
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
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
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
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.
Abdulrehman Khan
Abdulrehman Khan 2016 年 11 月 28 日
Thanks @KSSV It was useful And @Jan Simon this question is not part of my HW it is a task of group studying.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by