万能单链表
main 函数,测试代码
#include <stdio.h>
#include <stdlib.h>
#include "slinkedlist.h"
typedef struct Stu{
int no;
char name[40];
int score[3];
}Stu;
int comp_no(const void *v1,const void *v2){
const struct Stu *ps1 = (const struct Stu *)v1;
const struct Stu *ps2 = (const struct Stu *)v2;
return ps1->no - ps2->no;
}
int comp_name(const void *v1,const void *v2){
const struct Stu *ps1 = (const struct Stu *)v1;
const struct Stu *ps2 = (const struct Stu *)v2;
return strcmp(ps1->name,ps2->name);
}
void show_stu(const void *pv){
const Stu *pstu = (const Stu *)pv;
printf("%d %s %d %d %d\n",
pstu->no,pstu->name,pstu->score[0],pstu->score[1],pstu->score[2]);
}
int main(int argc, char *argv[]) {
SLinkedList list = slinked_list_create(sizeof(struct Stu));
struct Stu stus[]={
{
110,"张飞",{
54,67,40}},
{
120,"赵云",{
78,67,90}},
{
119,"关羽",{
60,83,100}},
{
127,"马超",{
67,87,99}},
{
101,