当前位置:网站首页>¥ 1-3 SWUST OJ 942: reverse sequence table
¥ 1-3 SWUST OJ 942: reverse sequence table
2022-07-25 09:39:00 【Ye Xiaobai】
Reverse order table
Title Description

Source code
#include<iostream>
#include<stdlib.h>
#include<malloc.h>
using namespace std;
typedef char ElemType;
class SqList
{
public:
ElemType data[100];
int length;
};
void CreateList(SqList *&L,ElemType a[],int n)// Create a sequence table
{
int i=0,k=0;
L=(SqList *)malloc(sizeof(SqList));
while(i<n)
{
L->data[k]=a[i];
k++;i++;
}
L->length=k;
}
void InitList(SqList *&L)// initialization
{
L=(SqList *)malloc(sizeof(SqList));
L->length=0;
}
void Inverse(SqList *&L)// Reverse order table
{
int i=0,k=L->length-1;
ElemType a[100];
while(i<L->length)
{
a[i]=L->data[k];
i++;k--;
}
i=0;
while(i<L->length)
{
L->data[i]=a[i];
i++;
}
}
void ShowList(SqList *L)
{
for(int i=0;i<L->length;i++)
{
if(i!=L->length)
{
cout<<L->data[i]<<" ";
}else
{
cout<<L->data[i];
}
}
}
int main()
{
int n;
ElemType a[100];
SqList *L;
cin>>n;
getchar();
for(int i=0;i<n;i++)
{
cin>>a[i];
}
CreateList(L,a,n);
Inverse(L);
ShowList(L);
return 0;
}
边栏推荐
猜你喜欢

【代码源】每日一题 - 排队

*6-2 CCF 2015-03-3 Festival

How to customize the title content of uni app applet (how to solve the problem that the title of applet is not centered)

Prim 最小生成树(图解)

Kotlin协程:协程的基础与使用

cell的定义

Data preprocessing
![[GKCTF 2021]easynode](/img/f0/1daf6f83fea66fdefd55608cbddac6.png)
[GKCTF 2021]easynode

Why use json.stringify() and json.parse()

解决esp8266无法连接手机和电脑热点的问题
随机推荐
Flex layout syntax and use cases
pdf2Image Pdf文件存为jpg NodeJs实现
【代码源】每日一题 简单字段和
【代码源】每日一题 - 排队
How to customize the title content of uni app applet (how to solve the problem that the title of applet is not centered)
Data query language (DQL)
[code source] daily question simple fields and
为什么要使用JSON.stringify()和JSON.parse()
UI原型资源
OC -- first acquaintance
正奇边形可划分成多少区域
Android & Kotlin : 困惑解答
cf #785(div2) C. Palindrome Basis
OC -- category extension agreement and delegation
laravel 调用第三方 发送邮件 (php)
[GKCTF 2021]easynode
Redis list 结构命令
Redis set 结构命令
OC -- Foundation -- dictionary
Singleton mode