📄 ch11_11.c
字号:
/*CH11_11*/
/*建立一个N个结点的链表,存放学生数据。为简单起见,我们假定学生数据结构中只有学号和年龄两项*/
#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define TYPE struct student
#define LEN sizeof (struct student)
struct student
{
int num;
int age;
struct student *next;
};
TYPE *creat(int n) /*定义函数。此函数带回一个指向链表头的指针*/
{
struct student *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)
pf=head=pb;
else pf->next=pb;
pb->next=NULL;
pf=pb;
}
return(head);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -