-1
再帰回文機能 これは 回文一部ではありませんが、あなたがif
文の中の方法ispalindrome(word, strlen(word))
を呼び出す必要が再帰回文機能
#include<iostream>
#include<cstring>
using namespace std;
bool ispalindrome(char string1[],int length);
int main()
{
string word;
cout<<"Enter a word: ";
cin>> word;
if(ispalindrome)
cout<<"The input word is palindrome";
else
cout<<"The input word is NOT palindrome";
return 0;
}
bool ispalindrome(char string1[],int length)
{
if(length<=1)
return true;
if ((*string1)==string1[length-1])
return ispalindrome(string1+1, length-2);
else return false;
}
あなたがエラーを書いたものをinteredにしたとき、それはこのリンクにあります。 http://store2.up-00.com/2016-10/1477696622041.png –
@ sh.alzoubiだから私はあなたがあなたのタイプと一致している。 'word'は' char * word = new char [1024] 'として宣言しなければなりません。 –
私は単語をcharに変更しました。これは私が受け取ったエラーです http://store2.up-00.com/2016-10/1477749413741.png –