C语言_简单链表(beta版)_Cplus17.2
来源:互联网 发布:sql去重复列名 编辑:程序博客网 时间:2024/06/01 11:29
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define TSIZE 45
struct film
{
char title[TSIZE];
int rating;
struct film *next;
};
main()
{
struct film *head=NULL;
struct film *prev,*current;
char input[TSIZE];
puts("Enter first movie title:");
while(gets(input)!=NULL&&input[0]!='\0')
{
current=(struct film *)malloc(sizeof(struct film));
if(head==NULL)
head=current;
else
prev->next=current;
current->next=NULL;
strcpy(current->title,input);
puts("input your rating<1~10>:");
scanf("%d",¤t->rating);
while(getchar()!='\n')
continue;
printf("please input the next\n");
prev=current;
}
if(head==NULL)
printf("no data entered!\n");
else
printf("here is the movie list\n");
current=head;
while(current!=NULL)
{
printf("%S %d\n",current->title,current->rating);
current=current->next;
}
current=head;
while(current!=NULL)
{
free(current);
current=current->next;
}
printf("BYE!\n");
}
#include<string.h>
#include<stdlib.h>
#define TSIZE 45
struct film
{
char title[TSIZE];
int rating;
struct film *next;
};
main()
{
struct film *head=NULL;
struct film *prev,*current;
char input[TSIZE];
puts("Enter first movie title:");
while(gets(input)!=NULL&&input[0]!='\0')
{
current=(struct film *)malloc(sizeof(struct film));
if(head==NULL)
head=current;
else
prev->next=current;
current->next=NULL;
strcpy(current->title,input);
puts("input your rating<1~10>:");
scanf("%d",¤t->rating);
while(getchar()!='\n')
continue;
printf("please input the next\n");
prev=current;
}
if(head==NULL)
printf("no data entered!\n");
else
printf("here is the movie list\n");
current=head;
while(current!=NULL)
{
printf("%S %d\n",current->title,current->rating);
current=current->next;
}
current=head;
while(current!=NULL)
{
free(current);
current=current->next;
}
printf("BYE!\n");
}
0 0
- C语言_简单链表(beta版)_Cplus17.2
- C语言_简单的控制台版2048_源码
- C语言_动态链表的简单建立与节点删除
- c语言链表_递归_创建和输出
- c语言_数据结构_单向循环链表
- c语言_数据结构_双向循环链表
- c语言_数据结构_双向循环链表
- c语言_数据结构_顺序表
- 【C语言】C语言实现简单的链表
- C语言_链表_结构体_电话簿简单实现
- C语言数据结构_链表的实现
- c语言_链表实例讲解(两个经典例子)
- 01_链表的翻转(C语言)
- C语言 链表的简单操作
- c语言简单的链表
- 简单链表C语言实现
- c语言简单链表实现
- c语言实现简单链表
- c++常量折叠
- abort函数
- IP地址之计算 相关
- HDU1198
- HDU1216
- C语言_简单链表(beta版)_Cplus17.2
- HDOJ-----1084结构体排序
- 浏览器内核比较
- SODBASE运维----Linux下SODBASE CEP集群命令
- 求了一天的割点
- django 使用mysql 出现的 No module named MySQLdb
- Delphi-将ListView内容导出到文件
- 五大常用算法之三:贪心算法
- HDU1873