当前位置:网站首页>¥ 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;
}
边栏推荐
猜你喜欢
随机推荐
[code source] National Railway
What is cerebral fissure?
Flex layout syntax and use cases
Dream set sail (the first blog)
Redis set 结构命令
Student management system (summary)
一张图讲解 SQL Join 左连 又连
[code source] a prime number of fun every day (BFS)
OC--包装类和处理对象
深入解读C语言随机数函数和如何实现随机数
换电脑后如何配置SSH
Swift简单实现待办事项
链表--基本操作
关于学生管理系统(注册,登录,学生端)
How to deploy the jar package to the server? Note: whether the startup command has nohup or not has a lot to do with it
main函数的一些操作
cell的定义
Redis string 结构命令
Redis string structure command
How to customize the title content of uni app applet (how to solve the problem that the title of applet is not centered)
![[code source] I have a big head for a problem every day](/img/02/cb083e247fe1f8374020db4b803758.png)








