#include<iostream>
using namespace std;
struct Number
{
int number;
Number *next;
};
Number *head = new Number;
Number *Create(int &n)
{
Number *pS, *pEnd;
pS = new Number;
cin >> pS->number;
pEnd = pS;
head = pS;
while (--n)
{
pS = new Number;
cin >> pS->number;
pEnd->next = pS;
pEnd = pS;
}
pEnd->next = NULL;
delete pS;
return head;
}
void ShowList(Number *head)
{
while (head)
{
cout << head->number << " ";
head = head->next;
}
}
int main()
{
int n;
cin >> n;
ShowList(Create(n));
return 0;
}
[2116] - 数据结构实验之链表一:顺序建立链表(C++版本)
最新推荐文章于 2023-05-26 03:45:00 发布