vendredi 13 septembre 2019

Why won't this code be executed Palindrome

Code runs but does nothing I'm not sure why palindrome. is there problem with my array of string?

#include <iostream>
#include <string>
using namespace std;

bool palindrome(string C, int begin, int end) {
    for (;begin<end;begin++, end--){
        if (C[begin] != C[end])
            return 0;
    }
    return 1;
}

int main()
{
    string arr1 = "aba";
    cout << palindrome(arr1, 0, 2) << endl;


}

Aucun commentaire:

Enregistrer un commentaire