xinxina. 2024-03-26 11:20 采纳率: 100%
浏览 3
已结题

怎么在main函判断是不是回文,help me




``
#include "stdio.h"
#include "string.h"
#include "math.h"
#include "malloc.h"
#include "stdlib.h"

#define STACK_TNTI_SIZE 100
#define STACKINCREMENT 10

#define  TRUE 1
#define  ERROR 0
#define  FALSE 0
#define  OK 1
#define  INFEASIBLE -1
#define  OVERFLOW -2

typedef char SElemType;
typedef int Status; 

typedef struct                                                                                                                  
{
    SElemType *base;
    SElemType *top;
    int stacksize;
}SqStack;

Status StackEmpty(SqStack S);
Status initstack(SqStack *S);
Status Push(SqStack *S ,SElemType e);
Status Pop(SqStack *S, SElemType *e);

Status StackEmpty(SqStack S){
    if (S.top = S.base)
        return TRUE;
}

Status initstack(SqStack *S){
    S->base = (SElemType *)malloc(STACK_TNTI_SIZE * sizeof(SElemType));
    if(!S->base) exit (OVERFLOW);
    S->top = S->base;
    S->stacksize = STACK_TNTI_SIZE;
    return OK;
}

Status Push(SqStack *S, SElemType e){
    if(S->top - S->base >= S->stacksize){
        S->base = (SElemType *)realloc(S->base,(S->stacksize + STACK_TNTI_SIZE)*sizeof(SElemType));
        if (!S->base) exit(OVERFLOW);
        S->top = S->base + S->stacksize; 
        S->stacksize += STACKINCREMENT;
    }
    *(S->top++) = e;   /*   *(S->top) = e; S->top++;  */
    return OK;
}

Status Pop(SqStack *S, SElemType *e)
{
    if(S->top == S->base) return ERROR;
    *e = *(--S->top); 
    return OK;
}

#define MAXQSIZE 100  

typedef char QElemType;

typedef struct{
    QElemType *base;
    int front;
    int rear;
}SqQueue;

Status InitQueue (SqQueue *Q);
int QueueLength (SqQueue Q);
Status EnQueue (SqQueue *Q, QElemType e);
Status DeQueue (SqQueue *Q, QElemType *e);

Status InitQueue (SqQueue *Q){
    Q->base = (QElemType * ) malloc (MAXQSIZE * sizeof (QElemType));
    if(!Q->base) exit (OVERFLOW);
    Q->front = Q->rear = 0;
    return OK;
}

int QueueLength (SqQueue Q){
    return(Q.rear - Q.front + MAXQSIZE) % MAXQSIZE;
}

Status EnQueue (SqQueue *Q, QElemType e){
    if ((Q->rear + 1) % MAXQSIZE == Q->front) return ERROR; 
    /* *((*Q).base + Q->rear) = e;*/
    Q->base[Q->rear] = e;
    Q->rear = (Q->rear + 1) % MAXQSIZE;
    return OK;
}

Status DeQueue (SqQueue *Q, QElemType *e){
    if (Q->front == Q->rear)  
        return ERROR;
    *e = Q->base[Q->front]; 
    /*   e = *((*Q).base + (*Q).front);  */
    Q->front = (Q->front + 1) % MAXQSIZE;
    return OK;
}


int main(){

    SqQueue Q;
    SqStack S;
    SElemType e;
    QElemType m;
    InitQueue (&Q);
    initstack(&S);
  • 写回答

3条回答 默认 最新

  • xinxina. 2024-03-26 11:20
    关注

    大佬们,救救孩子吧😮‍💨

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 4月3日
  • 已采纳回答 3月26日
  • 创建了问题 3月26日

悬赏问题

  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗