线性表

栈&队列

二叉树

持续更新中,尽请期待!!!

#include <bits/stdc++.h>
using namespace std;

typedef char datatype;
const int maxsize = 1024;
typedef struct
{
   
    datatype data[maxsize];
    int last;
} SeqList, *PSeqList;

void creat(PSeqList &L)
{
   
    L = new SeqList;
    L->last = 0;
    char ch;
    while ((ch = getchar()) != '*')
    {
   
        L->data[L->last] = ch;
        L->last++;
    }
}

void invert(PSeqList &L)
{
   
    int n = L->last / 2;
    for (int i = 0; i < n; i++)
    {
   
        char temp = L->data[i];
        L->data[i] = L->data[L->last - i - 1];
        L->data[L->last - i - 1] = temp;
    }
}

void print(PSeqList &L)
{
   
    for (int i = 0; i < L->last; i++)
        cout << L->data[i] << " ";
    cout << endl;
}

int main()
{
   
    PSeqList L;
    creat(L);
    print(L);
    invert(L);
    print(L);
    return 0;
}