char str[50];
int start = 0, pcheck = 0, end;
cout << "Enter String : ";
cin >> str;
cout << "Result ";
end = strlen(str);
end = end - 1;
while ((end > start) && (pcheck == 0))
{
while (!ischeckchar(str[start]))start++;
while (!ischeckchar(str[end]))end--;
if (toupper(str[start]) != toupper(str[end])) pcheck = 1;
start++;
end--;
}
if (pcheck == 0)
cout << "This message is palindome. " << endl;
else
cout << "This message is not palindome. " << endl;
ไม่มีความคิดเห็น:
แสดงความคิดเห็น