麻烦大家了
#define NULL 0#define TYPE struct stu
#define LEN sizeof (struct stu)
struct stu
{
int num;
int age;
struct stu *next;
};
TYPE *creat(int n)
{
struct stu *head,*pf,*pb;
int i;
for(i=0;i<n;i++)
{
pb=(TYPE*) malloc(LEN);
printf("input Number and Age\n");
scanf("%d%d",&pb->num,&pb->age);
if(i==0) 第一次循环的时候i是不是等于0
pf=head=pb; 这句怎么理解为什么=0就要把pb的直赋予这两个指针变量
else pf->next=pb; 这句是不是把pb的地址赋予pf->next
pb->next=NULL;
pf=pb; 这句是不是把pb的数据赋予pf
return(head); 为什么最后输出的是这个变量
}
我是新手 理解不进 麻烦解释下 看了很久就是理解不了
搜索更多相关的解决方案:
麻烦
----------------解决方案--------------------------------------------------------
楼主能不能先排个版。。。。。。。
/*****************************************************************
** HighlightCodeV3.0 software by yzfy(雨中飞燕) http://yzfy.org **
*****************************************************************/
#define NULL 0
#define TYPE struct stu
#define LEN sizeof (struct stu)
struct stu
{
int num;
int age;
struct stu *next;
};
TYPE *creat(int n)
{
struct stu *head,*pf,*pb;
int i;
for (i=0;i<n;i++)
{
pb=(TYPE*) malloc(LEN);
printf("input Number and Age\n");
scanf("%d%d",&pb->num,&pb->age);
if (i==0) //第一次循环的时候i是不是等于0
pf=head=pb; //这句怎么理解为什么=0就要把pb的直赋予这两个指针变量
else pf->next=pb; //这句是不是把pb的地址赋予pf->next
pb->next=NULL;
pf=pb; //这句是不是把pb的数据赋予pf
return(head); //为什么最后输出的是这个变量
}
}
** HighlightCodeV3.0 software by yzfy(雨中飞燕) http://yzfy.org **
*****************************************************************/
#define NULL 0
#define TYPE struct stu
#define LEN sizeof (struct stu)
struct stu
{
int num;
int age;
struct stu *next;
};
TYPE *creat(int n)
{
struct stu *head,*pf,*pb;
int i;
for (i=0;i<n;i++)
{
pb=(TYPE*) malloc(LEN);
printf("input Number and Age\n");
scanf("%d%d",&pb->num,&pb->age);
if (i==0) //第一次循环的时候i是不是等于0
pf=head=pb; //这句怎么理解为什么=0就要把pb的直赋予这两个指针变量
else pf->next=pb; //这句是不是把pb的地址赋予pf->next
pb->next=NULL;
pf=pb; //这句是不是把pb的数据赋予pf
return(head); //为什么最后输出的是这个变量
}
}
----------------解决方案--------------------------------------------------------
我是在这里看书看到这里 什么叫排版不懂啊
----------------解决方案--------------------------------------------------------
就是让你好好按规矩写程序
看了下,你的书没好好看啊
----------------解决方案--------------------------------------------------------
这是链表,好好看下数据结构里面的链表。
----------------解决方案--------------------------------------------------------