C语言代码创建一个链表,并对链表进行插入元素,删除元素和销毁链表操作。并写出测试用例。

来源:百度知道 编辑:UC知道 时间:2024/05/07 06:31:18

已在VC6环境下调试通过.
#include<stdio.h>
#include<string.h>
#include<malloc.h>
struct student
{
long number;
char name[8];
float score;
struct student *next;
}*head=NULL;
int sum=0; //计数

void main()
{
void show();
void insert();
void del();
char command[6];
printf("***********************************************************\n");
printf(" 链表综合练习程序\n\n");
printf("***********************************************************\n");
while(1)
{ printf("请输入操作命令,(输入help查看帮助):\n");
scanf("%s",command);
if(strcmp(command,"exit")==0) break; //输入exit结束循环
else if(strcmp(command,"insert")==0) insert();
else if(strcmp(command,"show")==0) show();
else if(strcmp(command,"insert")==0) insert();
else if(strcmp(com