📄 zifuduichen.c
字号:
#define NULL 0 //buhaoshidele
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#define maxsize 20
typedef struct node
{
char strdata;
struct node *next;
}Llist;
typedef struct nodestack
{
char stackdata[maxsize];
int top;
}stack;
Llist *creat(int n)
{
int j;
char ch;
Llist *head,*p,*q;
p=(Llist *)malloc(sizeof(Llist));
p->strdata=0;
p->next=NULL;
head=p;
for(j=1;j<=n;j++)
{
ch=getchar();
q=(Llist *)malloc(sizeof(Llist));
q->strdata=ch;
q->next=NULL;
p->next=q;
p=p->next;
}
return(head);
}
stack *push(stack *s,char x)
{
if(s->top==(maxsize-1))
printf("overflow");
else
{s->top=s->top+1;
s->stackdata[s->top]=x;
}return(s);
}
char popup(stack *s)
{
char p;
if(s->top==-1)
printf("empty stack");
else
{
p=s->stackdata[s->top];
s->top=s->top-1;
}
return(p);
}
void main()
{
stack *s;
Llist *p,*head;
int flag=0,n,i;
s=(stack *)malloc(sizeof(stack));
s->top=-1;
printf("please Input interger n(1--maxsize)and n wei string\n");
scanf("%d",&n);
head=creat(n);
p=head->next;
for(i=0;i<n/2;i++)
{
push(s,p->strdata);
p=p->next;
}
if(n%2==1 && n>1)
do
{
p=p->next;
flag=(popup(s)==p->strdata);
}
while(s->top!=-1 && flag==1);
if(n==0)
printf("error opration");
else if(flag==1 || n==1)
printf("zi fu chaun shi zhong xin dui chen de!\n");
else
printf("zi fu chuan bu dui chen");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -