建立一个链表存放学生信息并打印信息
2014-04-01 22:29
387 查看
#include<stdio.h> #include<stdlib.h> #define len sizeof(pNode) typedef struct student { long num; float score; struct student *next; }*pNode; int n;/*一个全局变量*/ pNode creat() { pNode head,p1,p2; n=0; p1=p2=(pNode)malloc(len); head=NULL; scanf("%ld %f",&p1->num,&p1->score); while(p1->num!=0) { n++; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(pNode)malloc(len); scanf("%ld %f",&p1->num,&p1->score); } p2->next=NULL; return head; } void print(pNode head) { pNode p; printf("Now,these %d records are :\n",n); p=head; if(head!=NULL) { do { printf("%ld %5.1f\n",p->num,p->score); p=p->next; }while(p!=NULL); } } int main() { pNode head; head=creat(); print(head); return 0; }
相关文章推荐
- 编写程序:建立一个学生数据链表,每个节点的信息包括如下内容:学号,姓名,性别年龄专业。对链表做如下处理。输入一个学号(专业),如果链表中的节点包含此学号(专业),则删去该结点。
- 建立一个学生结构数组来记录学生信息(学号ID,姓名和C语言成绩),要求动态建立一个结构数组,数组长度从键盘输入,自行给数组元素赋值并打印学生信息,最后不要忘记释放内存。 结构st
- 【C++】建立一个学生信息链表,每个结点包括:学号、姓名、成绩。【原创技术】
- 【C++】建立一个学生信息链表,每个结点包括:学号、姓名、成绩。【原创技术】
- iOS中C语言的打印一个或多个学生信息
- 一个学生的信息是:姓名,学号,性别,年龄等信息,用一个链表,把这些学生信息连在一起, 给出一个age, 在些链表中删除学生年龄等于age的学生信息
- 建立一个简单的链表,它由三个学生数据的结点组成输出各节点中的数据。
- 建立学生信息链表
- 一个链表程序,支持建立,插入,删除,输出;学生的学号和分数
- 一个简单的学生信息管理系统(循环双向链表)
- 例 9.8 建立一个如图9.9所示的简单链表,它由3个学生数据的结点组成,要求输出各结点中的数据。
- 我想用 VS2005 建立一个学生信息查询系统,但是调试的时候显示“当前上下文中不存在···”
- 数据结构课程设计 建立一个学生管理系统,以单链表的形式存储,学生信息包括学号,姓名,年龄,出勤,奖励惩罚,电话号码
- 链表的基本操作 (1)采用尾插法建立一个链表; (2)输入一个元素,在道表中查找该元素是否存在,请给出相关信息; (3)将链表中的元素进行就地逆置。
- 第八周项目-建立一个简单的学生信息表
- 6-4 建立学生信息链表(20 分)——尾插建链表_题程序访问是越界——真是醉了,你自己跑下是会抛出异常的
- 一个学生的信息是:姓名,学号,性别,年龄等信息,用一个链表,把这些学生信息连在一起, 给出一个age, 在些链表中删除学生年龄等于age的学生信息。
- PTA 4-1 建立学生信息链表 (50分)
- Map接口常用方法:定义一个Map,存放学生信息
- 创建一个学生类(Student),包括学号和成绩,编程输入和显示学生的信息,建立一个人类(Person),包含姓名、性别和年龄,并作为学生类的基类