#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//若处理器是Big_endian的,则返回0;若是Little_endian的,则返回1。
int checkCPU(void)
{
union
{
int a;
char b;
}c;
c.a = 1;
return (c.b == 1);
}
bool palindrome( char *const s1, char *const s2)
{
int l1 = strlen(s1);
int l2 = strlen(s2);
if(l1 != l2)
return false;
int cnt1 = 0;
char *h1 = s1;
char *t2 = (s2 + l2 - 1);
while(cnt1 < l1 && *h1++ == *t2--)
cnt1++;
if(cnt1 == l1)
return true;
else
return false;
int cnt2 = 0;
char *t1 = (s1 + l1 - 1);
char *h2 = s2;
while(cnt2 < l1 && *t1-- == *h1++)
cnt2++;
if(cnt2 == l1)
return true;
else
return false;
}
int main()
{
char* const s1 = "lee";
char* const s2 = "eelw";
bool flag = palindrome(s1, s2);
if(flag == true)
printf("paralindrome!\n");
else
printf("no!\n");
system("pause");
return 0;
}