一道综合应用题,c语言包含数据结构的知识,求科普数据结构。

直接上题没有描述
#include<stdio.h>
#include<stdio.h>
struct node
{int num;
struct node *next
};
struct node *creat(struct node *head)
{
struct node *p1,*p2;
p1=p2=(strcutnode*)malloc(sizeof(struct node));
p1->next=NULL;
while(p1->num>0)
{
if(head==NULL)
空一head=p1;
else
空二p2->next=p1;
p2=p1;
p1=(struct node*)malloc(sizeof(struct node));
空三scanf("%d",&p1->num)
}
return head;
}
void print(struct node*head)
{
struct node*temp;
空四temp=head;
while(temp!=NULL)
{printf("%",空五temp->num);
temp=temp->next;
}
}
main()
{struct node*creat();
void print();
struct node*head;
head=NULL;
head=creat(head);
print(head);
}
内容看不懂,一带指针我就晕,有没有指针记忆要点公式类似的东西。还有就是,描述下是怎么解题的,思路怎么来的。

指针这个东西很不好理解。就把他当火车头理解吧,通过火车头可以找到火车,火车有多少车厢,这些他都不管,他只管自己的类型,是高铁还是快速还是普快什么的。
举个例子 int * p 他就是一个int火车车厢的车头, 如果他指向 int a【10】 就是说他现在拖着10个int车厢。 *p是第0个车厢, p+1就是第一个车厢。

上面就是创建列表。就把他挡成一节一节车厢挂到车头的过程吧。。

高级的指针用法,可能指针的指针,结构体指针等,就把它当着高级专列,或者火车上的一个车厢又装了玩具火车理解。。

参考:编程中国风

步步高指针机,哪里不会指哪里,so esay
温馨提示:答案为网友推荐,仅供参考
相似回答