資源簡介
C語言鏈表創建與逆序輸出
代碼片段和文件信息
#include?
#include?
#define?N?sizeof(struct?x)
struct?x
{
int?num;
struct?x?*next;?
};?
struct?x?*creat(void)
{
struct?x?*p1*p2*head;
head=p2=(struct?x?*)malloc(N); //headp2指向頭結點
p1=(struct?x?*)malloc(N); //p1創建新結點?
scanf(“%d“&p1->num);?
while(p1->num!=-1)
{
p2->next=p1; //連接p2->p1兩個結點?
p2=p1; //p2向p1挪動?
- 上一篇:c++ 三次樣條曲線擬合
- 下一篇:c++ 九九乘法表
評論
共有 條評論