C语言 数据结构线性表的问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 14:11:54
创建线性表,有用户决定数据的个数。请用户输入数据,输出数据,及线性表的长度,询问是否查找数据,若查找则由用户输入需查找的数据,显示此数据在线性表中的位置(第几个)

/*
创建线性表,有用户决定数据的个数。请用户输入数据,输出数据,及线性表的长度,
询问是否查找数据,若查找则由用户输入需查找的数据,显示此数据在线性表中的位置(第几个)
*/
#include <stdio.h>
#include <stdlib.h>
#define NULL 0
#define LEN sizeof(struct Node)
struct Node
{
int num;
struct Node* next;
};
struct Node *createline();
void showline(struct Node *head);
int getlen(struct Node *head);
int selectline(struct Node *head,int data);
int main()
{
struct Node *head;
int selflag;
int len = 0;
head = createline();
if(head == NULL)
{
printf("create error\n");
return 1;
}
showline(head);
printf("line's len is %d\n",getlen(head));
printf("0 select,other not select\n");
scanf("%d",&selflag);
if(selflag == 0)
{
printf("请输入要查找的数字:");
scanf("%d",&selflag);
len = selectline(head,selflag