收藏 分销(赏)

判断字符串是否为回文数.doc

上传人:仙人****88 文档编号:11257951 上传时间:2025-07-11 格式:DOC 页数:3 大小:24.50KB 下载积分:10 金币
下载 相关 举报
判断字符串是否为回文数.doc_第1页
第1页 / 共3页
判断字符串是否为回文数.doc_第2页
第2页 / 共3页


点击查看更多>>
资源描述
源代码: #include<stdio.h> #include<malloc.h> #define null 0 #define max 50 typedef struct sn{ char data; struct sn *next; }node; int ishw(node *head,int n){ char stack[max];     int top=0;     node *p;     p=head->next;     while(top<n/2)     {         stack[top]=p->data;         top++;         p=p->next;     }     top--;     if(n%2==1) p=p->next;     while(top>=0)     {         if(stack[top]!=p->data) return 0;         top--;         p=p->next;     }     return 1; } int push(node *head,char *s) {   int i; node *p,*q;     p=head;     for(i=0;s[i]!='@';i++)     {       q=(node *)malloc(sizeof(node));         q->data=s[i];         q->next=null;         p->next=q;         p=q;     }    return(i); } void main() {   char s[max];    node *head;    int i;     printf("Please input a data(max size: %d):",max);     scanf("%s",s);     head=(node *)malloc(sizeof(node));     i=push(head,s);     if(ishw(head,i))         printf("It is a huiwenshu.\n");     else         printf("It is not a huiwenshu.\n"); }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服