// Return true if str is a palindrome
bool is_palindrome (char* str) {
int len;
char* cpy;
char* ptr;
bool b;
len = strlen (str);
if (!len) return false;
cpy = malloc (sizeof(char) * (len + 1));
ptr = cpy;
while (*ptr=*str)
{
if (*ptr>='A' *ptr<='Z') *ptr+=('a'-'A');
if ((*ptr>='a' && *ptr<='z') (*ptr>='0' && *ptr<='9')) {
++ptr;
} ++str;
} *ptr = '\0';
--ptr;
str = cpy;
while ((cpy!=ptr) && (cpy!=(ptr+1)) && (*cpy==*ptr))
{
++cpy;
--ptr;
}
b = (*cpy==*ptr);
free (str);
return b;
}
sdfdg
/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }
Private Sub Command1_Click() a = Text1.Text b = StrReverse(a) If a = b Then Print "palindrome" Else Print "not palindrome" End If End Sub
Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!
import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i<failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}
sdfdg
Reverse the string and compare it to the original. If they match, then it is a palindrome.
To check if a string is a palindrome, point to each end of the string and work inwards towards the middle. If the characters pointed at differ, the string is not a palindrome. When the pointers meet or cross each other, the string is a palindrome. Note that the string cannot contain whitespace or punctuation and comparisons must not be case-sensitive.
A string palindrome is some words that put together form a sentence. An example is "A man, a plan, a canal - Panama".
A string palindrome is some words that put together form a sentence. An example is "A man, a plan, a canal - Panama".
/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }
You could use a function like this:function isPalindrome($string) {$string = strtolower($string);return (strrev($string) == $string) ? true : false;}and then to check a palindrome call an if statement like so:if(isPalindrome($test)) {echo $test.' is a palindrome';}else {echo $test.' is not a palindrome';}
Private Sub Command1_Click() a = Text1.Text b = StrReverse(a) If a = b Then Print "palindrome" Else Print "not palindrome" End If End Sub
Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!
import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i<failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}
If you mean the number 1,111 or simply 1111, this is a palindrome. A palindrome is a string or number that is spelled or written the same way forward and backward.
palindrome in every language means same. it means on reversing a number or string, if we get the same number or string as the case may be ,then the number or string is called palindrome. eg: 1221,111,252 or LIRIL,MADAM etc .