回文判断
发布日期:2021-06-29 14:39:26 浏览次数:3 分类:技术文章

本文共 636 字,大约阅读时间需要 2 分钟。

//群:970353786#include"stdio.h"#include"stdlib.h"typedef char ElemType;typedef struct stnode{
ElemType data; struct stnode* next;}StNode, * LinkStack;int huiwen(char str[]){
int i = 0; char ch; StNode* sl = NULL, * p; while ((ch = str[i++]) != '\0') {
p = (StNode*)malloc(sizeof(StNode));//给内存 p->data = ch; p->next = sl; sl = p; } i = 0; while (sl != NULL) {
p = sl; ch = p->data; sl = sl->next; free(p);//释放内存 if (ch != str[i++]) return 0; } return 1;}void main(){
char string[30];//最长为30 int hw; printf("请输入字符串:"); gets_s(string); hw = huiwen(string); if (hw) printf("字符串是回文."); else printf("字符串不是回文");}

转载地址:https://chuanchuan.blog.csdn.net/article/details/116906255 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:任意进制转换
下一篇:指针定义和理解

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月18日 08时06分06秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章