jeudi 20 septembre 2018

How to check if one string is reverse of the other using recursion in cpp.Please check the error in the code

#include  <iostream>
using namespace std;


bool is_reverse(char s1[],char s2 [],int n1,int n2)
{


  if(n1==n2)

    {
        return false;

    }


    if(s1[0]==s2[n2-1])
    {
        return is_reverse(s1,s2,n1+1,n2-1);
    }

        return false;

}




int main()
{


char s1[]="abcde";


    char  s2="edcba";



    int A=0;
    int B=s2.length();
    cout<<is_reverse(s1,s2,A,B);

}

Aucun commentaire:

Enregistrer un commentaire