
给定一个句子,挑战是从给定的句子中找到最长的回文
什么是回文?
回文是一个单词或序列,即使在之后其含义仍然保持不变反转字符串
示例 - Nitin,反转字符串后其含义保持不变。
挑战是从给定的句子中找到最长的回文。
喜欢的句子是:malayalam liemadameil iji
它包含三个回文词,但最长的是 - liemadameil
算法
START STEP 1 -> Declare start variables I, j, k, l, max to 0, index to -1, check to 0, count to 0 Step 2 -> Loop For i to 0 and iEnd Loop For Step 4 -> Loop For i = index and i!=-1 && str[i]!=' ' && str[i]!='\0' and i++ Print str[i] Step 5 -> End Loop For STOP
示例
#include#include int main(int argc, char const *argv[]) { char str[] = {"malayalam liemadameil iji"}; int i, k, l, j, max =0, index = -1, check = 0, count = 0; for(i=0; i 输出
如果我们运行上面的程序,它将生成以下输出。
liemadameil











