第二周学习进度

#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define MAX 100
#define  DataType char

typedef struct 
{
    DataType elem[MAX];
    int top;
}SeqStack;

void intStack(SeqStack*s)    //初始化
{
    s->top=-1;
}

int push(SeqStack *s,DataType x)//进栈
{
    if(s->top>=MAX-1)
    {
        printf("full\n");
        return 0;
    }
    s->top++;
    s->elem[s->top]=x;
    return 1;
}




int pop(SeqStack *s,DataType*x)//出栈
{
    if(s->top ==-1)
    {
        printf("empty\n");
        return 0;
    }
    *x=s->elem[s->top];
    s->top--;
    return 1;


}



int main()
{
    SeqStack s;        
    intStack(&s);    
    DataType x,y;
    char str[20];
    printf("请输入一个字符串,输入@结束:\n");
    scanf(" %s",str);
    int i;
    
    for(i=0 ;i<=20;i++)
    {
        
        if (str[i]=='@')
            break;
        push(&s,str[i]);    //进栈
    }
    int j=0;
    while(s.top!=-1 &&j<i)
    {
        pop(&s,&y);            //出栈
        if(y==str[j])
        {
            j++;
        }else
        {
            break;
        }
    }
            
    if (s.top ==-1 && j==i)
        printf("这是回文");
    else
        {
            j=0;
                while (str[j]!='@')
                    {
                        printf("%c",str[j]);
                        j++;
                    }
                printf("不是回文");
            }
        printf("\n\n");
    return 0;
}

 

日期 学习方法 学习时间 新增代码行 知识总结
星期一 看视频  2h    
星期二 看视频  1h    
星期三        
星期四 看视频  2h    
星期五        
星期六 看视频 、做练习 1h    
星期日 看视频 、做练习 2h 100  
总计 看视频 、做练习  8h 200  
posted @ 2020-05-03 22:21  VousAime  阅读(131)  评论(0)    收藏  举报