数据结构实验一

数据结构实验一,第1张

#include
using namespace std;
#include
struct people
{
string name;
int num;
};
template
struct Node
{
T data;
Node*next;
};
template
class LinkList
{
Node*head;
public:
LinkList();
LinkList(T a[],int n);
~LinkList();
void PrintLinkList();
};
template
LinkList::LinkList()
{
head=new Node;
head->next=NULL;
}
template
LinkList::LinkList(T a[],int n)
{
head=new Node;
rear=head;
for(i=0;i {
s=new Node;
s->data=a[i];
rear->next=s;
rear=s;
}
rear->next=NULL;
}
template
void LinkList::PrintLinkList()
{
p=head->next;
while§
{
cout p=p->next;
}
}
int main()
{
int i;
string a[5]={“gh”,“hu”,“mk”,“se”,“KK”};
int b[5]={111,222,333,444,555};
people p[5];
for(i=0;i<5;i++)
{
p[i].name=a[i];
p[i].num=b[i];
cout< cout< cout<

}
return 0;

}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/565057.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-06
下一篇 2022-04-06

发表评论

登录后才能评论

评论列表(0条)

保存