⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 huiwenshu.c

📁 数据结构里关于回文数判断的算法 另一种思路另一种解决办法~
💻 C
字号:
#include <stdio.h>
#define false -1
#define OK     1
#define   StackElementType  char
typedef struct node
{  StackElementType data;
   struct node  *next;

}LinkStackNode;
typedef LinkStackNode *LinkStack;
/*初始化堆栈*/
void InitStack(LinkStack *top)
       {   *top=(LinkStack)malloc(sizeof(LinkStackNode));
           (*top)->next=NULL;
        }
/*进栈函数*/
int Push(LinkStack top,StackElementType x)
{    LinkStackNode *temp;
     temp=(LinkStackNode *)malloc(sizeof(LinkStackNode));
     if(temp==NULL)
     return (false);
     temp->data=x;
     temp->next=top->next;
     top->next=temp;
     return (OK);
}
/*出栈函数*/
int Pop(LinkStack top,StackElementType *x)
{  LinkStackNode *temp;
   temp=top->next;
   if(temp==NULL)
     return (false);
     top->next=temp->next;
     *x=temp->data;
     free(temp);
     return (OK);
}
main()
{  LinkStack Q;
   StackElementType *C,c1,c2;
   C=NULL;
   InitStack(&Q);
   printf("please input some chars that include(&):\n");
   scanf("%c",&c1);
   while(c1!='%')
     {  if(c1=='&')
       break;
        Push(Q,c1);
/*       scanf("%c",&c1); */
       c1=getchar();
      }
      /*printf("please output huiwenshu:"); */
     /* while(Q->next!=NULL)
         { Pop(Q,C);
           printf("%c",*C);
           }           */
       getch();
      printf("please input hou ban bu fen chars:");
     /* scanf("%c",&c2);        */
    c2=getchar();
    Pop(Q,C);
      while(c2!='@')
         while((Q->next!=NULL)&&(c2==*C))
           {  Pop(Q,C);
           /*   scanf("%c",&c2);   */
              c2=getchar();
           }

      getch();
   }






















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -