#include <iostream>
using namespace std;
typedef char Elemtype;
typedef struct _NList {
Elemtype value;
struct _NList* next;
}LinkList;
char arr[5] = {'a', 'b', 'c', 'b', 'a'};
void main() {
LinkList* L;
L = (LinkList *)malloc(sizeof(LinkList));
L->next = NULL;
LinkList *r, *s;
r = L;
int length = sizeof(arr) / sizeof(arr[0]);
int i = 0;
while (i < length) {
s = (LinkList *)malloc(sizeof(LinkList));
s->value = arr[i];
s->next = r->next;
r->next = s;
i++;
}
Elemtype *buffer1, *buffer2;
buffer1 = new Elemtype[length];
buffer2 = new Elemtype[length];
LinkList* x;
x = L->next;
int j = 0;
while (j < length) {
buffer1[j] = x->value;
buffer2[length-j-1] = x->value;
x = x->next;
j++;
}
int marker = 0;
for (int i = 0;i < length;i++) {
if (buffer1[i] != buffer2[i]) {
marker += 1;
break;
}
}
if (marker == 0) {
cout << "This string is a plalindrome!" << endl;
}
else {
cout << "This string is not a plalindrome!" << endl;
}
printf("end");
}