建立一个动态列表(结点的结构自拟)

来源:百度知道 编辑:UC知道 时间:2024/06/23 07:59:05
写出程序代码,输入是数据和输出结果,谢谢!!

楼上的也太复杂了,我给个简单的:
#include <stdio.h>
#include <malloc.h>
#include <string.h>

struct student
{
char name[20];
char sex[7];
int score ;
struct student * next;
};

main()
{
struct student *head=NULL;
struct student *p,*p1;
char name[20],sex[7];
int score;

//建立链表
while(1)
{
printf("Input name, sex and score:\n");
scanf("%s%s%d",name,sex,&score );
if(score<0)
{
break;
}
p1=(struct student *)malloc(sizeof(struct student));
p1->next=NULL;
strcpy(p1->name,name);
strcpy(p1->sex,sex);
p1->score=score;
if(head==NULL)
{
head=p1;
p=head;
}
else
{
p->next=p1;
p=p1;
}
}

//打印链表
p=head;
while(p!=NULL)
{
printf

如何建立一个80结点的局域网 求数据结构:建立一个带头结点的单链表函数 建立一个顺序表,并能够完成在指定位置插入一个新的结点。 建立一个网络的基础结构。 用C语言编写程序,创建一个二叉树的二叉链表结构,然后输出从根结点到所有叶子结点的路径。 怎样用做一个动态asp的下拉列表啊 采用二叉链表存储结构,按前根序输入二叉树的结点序列,建立二叉树并中根序遍历该二叉树,计算叶子节点的个数 建立一张图,用最短路径算法求出从指定结点的最短路径结点序列 编一程序:①建立一个数据域为1至10的带头结点的链表; 建立一个二叉树并打印出根结点的左孩子的内容,但是实现不了,请指教!!!!