大家看看这道C语言的问题 在线==

来源:百度知道 编辑:UC知道 时间:2024/05/26 07:35:32
建立结构,完成下面表格内容的输入和输出。第一个记录的输入用初始化完成,第2、3记录用键盘输入。记录定义为结构数组xs[N]。
学号 姓名 出生日期 成绩
81001 李明 1977.12.9 491.5
81025 张立明 1978.5.25 582
81133 朱方 1977.9.16 462.5

这是我写的一个,也是学生信息表,你看看,运行良好;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LIST_INIT_SIZE 100
#define LISTINCRMENT 10
#define OVERFLOW -1
#define OK 1
#define ERROR 0
typedef int status;
typedef int ElemType;

struct date {
char year[5];
char day[3];
};

struct student {
char name[10];
char number[6];
date birthday;
};

typedef struct {
struct student *elem;
int length;
int listsize;
}Sqlist;

status Initlist(Sqlist &L)
{
int i;
L.elem=(struct student *)malloc(LIST_INIT_SIZE*sizeof(struct student));
if (!(L.elem)) return ERROR;
L.length=5;
L.listsize=LIST_INIT_SIZE;
printf("请输入学生的基本信息\n");
for (i=0;i<5;++i) {
scanf("%s %s %s %s",L.elem[i].name,L.elem[i].number,L.elem[i].birthday.year,L.elem[i].birthday.