单向链表的建立,添加与删除(二)

2014-11-23 21:26:27 · 作者: · 浏览: 33
立新的链表\n");
printf("2--添加元素\n");
printf("3--删除元素\n");
printf("4--输出当前表中的元素\n");
printf("0--退出\n");


scanf("%d",&i);
switch(i)
{
case 1:
h=CreateList();/*创建链表*/
printf("list elements is : \n");
PrintList(h);
break;


case 2:
printf("input the position. of insert element:");
scanf("%d",&i);
printf("input name of the student:");
scanf("%s",name);
printf("input score of the student:");
scanf("%d",&score);
InsertList(h,i,name,score,count);
printf("list elements is:\n");
PrintList(h);
break;


case 3:
printf("input the position of delete element:");
scanf("%d",&i);
DeleteList(h,i,count);
printf("list elements in : \n");
PrintList(h);
break;


case 4:
printf("list element is : \n");
PrintList(h);
break;
case 0:
return;
break;
default:
printf("ERROR!Try again!\n");
}
}
return 0;
}