织梦做的网站怎样,手机购物网站开发,用什么软件做楼盘微网站,建设网站对公司起什么作用是什么意思版权声明#xff1a;本文为博主原创文章。未经博主同意不得转载。vasttian https://blog.csdn.net/u012860063/article/details/28281631 转载请注明出处#xff1a;http://blog.csdn.net/u012860063 问题#xff1a;设单链表中存放n个字符#xff0c;试设计一个算法#… 版权声明本文为博主原创文章。未经博主同意不得转载。vasttian https://blog.csdn.net/u012860063/article/details/28281631 转载请注明出处http://blog.csdn.net/u012860063 问题设单链表中存放n个字符试设计一个算法使用栈推断该字符串是否中心对称如xyzzyx即为中心对称字符串。 代码例如以下 #includecstdio
#includecstdlib
#includecstring
#define LEN sizeof(struct node)
#define MAX 147
struct node
{char cc;struct node *next;
};
int judge(struct node *head,int len)
{struct node *top,*p1,*p2;top NULL;p1 head-next;for(int i 0 ; i len/2 ; i){p2 (struct node *)malloc(LEN);p2-cc p1-cc;p2-next top;top p2;p1 p1-next;}if(len%2 1)p1 p1-next;p2 top;for(i 0 ; i len/2 ; i){if(p2-cc ! p1-cc)break;top p2-next;p1 p1-next;p2 top;}if(!top) return 1;else return 0;
}int main()
{int n0;char str[MAX];struct node *head,*p;head p (struct node *)malloc(LEN);head-next p-next NULL;printf(亲、请输入一个字符串\n);gets(str);int len strlen(str);while(n len str[0] ! \n){p (struct node *)malloc(LEN);p-cc str[n];p-next head-next;head-next p;n;}int flag judge(head,len);if(flag)printf(%s是一个回文!\n,str);elseprintf(%s不是一个回文!\n,str);return 0;
} 转载于:https://www.cnblogs.com/xfgnongmin/p/10742333.html