2021-9-23【数据结构】【顺序表逆置】
线性表
- 2021-9-14【数据结构/严蔚敏】【顺序表】【代码实现算法2.1-2.7】
- 2021-9-18【数据结构/严蔚敏】【单链表】【代码实现算法2.8-2.12】
- 2021-9-18【数据结构/严蔚敏】【静态链表】【代码实现算法2.13-2.17】
- 2021-9-19【数据结构/严蔚敏】【双向链表】【代码实现算法2.18-2.19】
- 2021-9-19【数据结构/严蔚敏】【带头结点的线性表】【代码实现算法2.20-2.21】
- 2021-9-19【数据结构/严蔚敏】【一元多项式的表示及相加、相减、相乘】【代码实现算法2.22-2.23】
- 2021-9-23【数据结构】【单链表逆置】
- 2021-9-23【数据结构】【顺序表逆置】
栈&队列
- 2021-9-22【数据结构/严蔚敏】【顺序栈&链式栈&迷宫求解&表达式求值】【代码实现算法3.1-3.5】
- 2021-9-27【数据结构/严蔚敏】【链队列】
- 2021-9-28【数据结构/严蔚敏】【循环队列】
串
二叉树
持续更新中,尽请期待!!!
#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;
}