数据结构与算法之顺序线性表

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/324419691646132.jpg "#left"

顺序表的话定义一个数组不就得了

供参考:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <time.h>
#define MaxLength 100
typedef struct Student {
    int id;
    char name[20];
    int score;
}Stu_Data;
typedef struct list {
    Stu_Data *data;
    int length;
}List;
int main()
{
    List s;
    int  i, n = 5;
    srand((unsigned int)time(NULL));
    s.data = (Stu_Data*)malloc(sizeof(Stu_Data) * MaxLength);
    s.length = 0;
    for (i = 0; i < n; i++)
    {
        s.data[i].id = i + 1;
        strcpy(s.data[i].name, "A");
        s.data[i].score = rand() % 100;
        s.length++;
    }
    printf("学号\t姓名\t分数\n");
    for (i = 0; i < s.length; i++)
        printf("%d\t%s\t%d\n", s.data[i].id, s.data[i].name, s.data[i].score);
    return 0;
}