创建链表和显示链表
来源:互联网 发布:我要开手机淘宝网店 编辑:程序博客网 时间:2024/04/29 22:18
#include <stdio.h>
#include <stdlib.h>
struct Stud
{
int no;
int score;
struct Stud *next;
};
//创建链表
struct Stud *create()
{
struct Stud *head, *p, *q;
int n, s;
head = (struct Stud *)malloc(sizeof(struct Stud));
head->next = NULL;
p = head;
while(1)
{
printf("学号 分数:");
scanf("%d%d",&n, &s);
if(n == 0 && s == 0)
{
break;
}
else
{
q = (struct Stud *)malloc(sizeof(struct Stud));
q->no = n;
q->score = s;
q->next = NULL;
p->next = q;
p = q;
}
}
return head;
}
//显示链表
void disp(struct Stud *h)
{
struct Stud *p = h->next;
printf("输出链表:");
if(p == NULL)
{
printf("空表\n");
}
else
{
while(p->next != NULL)
{
printf("%d %d,", p->no, p->score);
p = p->next;
}
printf("%d %d\n", p->no, p->score);
}
}
int main()
{
struct Stud *head;
head = (struct Stud *)malloc(sizeof(struct Stud));
head = create();
disp(head);
return 0;
}
- 创建链表和显示链表
- 链表创建,显示,删除和倒置
- 链表的创建和逆序显示
- 链表的创建、逆序显示、插入显示
- 简单链表,实现创建,显示,释放
- 创建随机长度链表并显示
- Project 1 :创建链表与显示链表
- 链表创建 和 倒置
- 创建和删除链表
- 链表的创建,插入,删除,显示,反转
- 创建和显示位图
- 创建和显示窗口
- Impala创建/显示表信息
- 链表创建和链表遍历
- 双向链表的创建和删除
- 链表的创建和遍历算法
- 链表的创建和操作
- 循环链表的创建和读取
- 如何通过配置文件动态创建对象
- CSDN关注别人blog方法
- 非常好用的GridView控件yyControls中的SmartGridView
- SRAM、DRAM、 SDRAM区别
- NOSQL
- 创建链表和显示链表
- POJ 1077 Eight A*
- RLE压缩和解压算法以及链表翻转
- 光驱没有
- NDK Hello
- 对C++ 的模板初步认识
- 一些转载的话
- HOWTO: Dump Call Stack
- copy 峡林 日志