#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=10010;
typedef struct
{
int *emue;
int lengh;
}lis;
void initlist(lis *L)
{
L->emue=new int [maxn];
L->lengh=0;
}
void creat(lis &L, int k)
{
L.lengh=k;
for(int i=0;i<L.lengh;i++)
{
cin>>L.emue[i];
}
}
void del(lis &L, int k)
{
for(int i=k;i<L.lengh-1;i++)
L.emue[i]=L.emue[i+1];
L.lengh--;
}
void loclist(lis &L)
{
for(int i=0;i<L.lengh-1;i++)
for(int j=i+1;j<L.lengh;j++)
{
if(L.emue[i]==L.emue[j])
{
del(L, j);
j--;
}
}
}
int main()
{
lis L;
int n, m;
cin>>m;
initlist(&L); ///���顺�表
creat(L, m); ///�顺�表��
loclist(L); ///å� é�¤é��å¤�å��ç´
cout<<L.lengh<<endl;
for(int i=0;i<L.lengh-1;i++)
cout<<L.emue[i]<<" ";
cout<<L.emue[L.lengh-1]<<endl;
return 0;
}
数据结构上机测试1:顺序表的应用
最新推荐文章于 2023-06-09 21:28:18 发布