国家开发银行高校贷款:c课程设计题帮我改改~~~

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 13:35:06
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#define AD struct student_list
struct student
{
char name[20];
char num[20];
char sex[10];
int age;
int grade;
};

AD
{
char name[20];
char num[20];
char sex[10];
int age;
int grade;
AD *next;
};

FILE *fp;
// 由文件中的数据生成管理系统的链表..如果文件不存在..则是一个空链;
AD *load(char filename[])
{
AD *p,*q,*head;
struct student stu;
head=(AD *)malloc(sizeof(AD));
q=head=NULL;
if((fp=fopen(filename,"rb"))==NULL)
return head;
else
{
while(!feof(fp))
{
if(fread(&stu,sizeof(struct student),1,fp)==1)
{
p=(AD *)malloc(sizeof(AD));
strcpy(p->name,stu.name);strcpy(p->num,stu.num);strcpy(p->sex,stu.sex);
p->age=stu.age;p->grade=stu.grade;
head=p;p->next=q;q=head;
}
}
fclose(fp);
return(head);
}
}

// 输入一条学生记录

AD *insert(AD *head)
{
AD *temp,*p;
p=head;
temp=(AD *)malloc(sizeof(AD));
printf("\n\t 请输入姓名:"); scanf("%s",temp->name);
printf("\n\t 请输入学号:"); scanf("%s",temp->num);
printf("\n\t 请输入性别:"); scanf("%s",temp->sex);
printf("\n\t 请输入年龄:"); scanf("%d",&(temp->age));
printf("\n\t 请输入成绩:"); scanf("%d",&(temp->grade));
head=temp;
temp->next=p;
return head;
}
程序写不完~~完整程序请来我空间看看~~
http://u13.qzone.qq.com/cgi-bin/cgi_client_entry.cgi?uin=83015937 谢谢啦~~