学生成绩管理系统用C语言结构体去写要求显示学生成绩管理,学生档案管理,查询和统计

学生成绩管理有修改和录入成绩功能。档案管理里面有读入,录入,修改,删除,储存学生信息功能。查询里有按学号查询,按姓名查询,排序和浏览。

第1个回答  2012-06-01
跟你的要求差不多,但是有点小差别,自己改改吧!
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NAME_MAX 100//书的名字的最长字数
#define WRITER_MAX 100//作者名字的最长
#define PUB_MAX 100//出版单位最长名字
#define TIME 100//出版时间

typedef struct books
{
int loading;
char name[NAME_MAX];
char writer[WRITER_MAX];
int identify;
char pub[PUB_MAX];
char time[TIME];
int price;
struct books * next;
}book;

//头结点不存储信息
void Init(book * head)
{
head->next=NULL;
}
//打印一些欢迎词之类的。。。。。
void welcome()
{
printf("******欢迎使用章强图书馆,哈哈*********\n");
printf("\n\n");
printf("1:图书信息录入功能\n");
printf("2:图书信息浏览功能,显示该书的所有信息\n");
printf("3:图书信息查询功能:按书名查询与按作者名查询\n");
printf("4:图书信息的修改和删除,可对相应数据进行修改和删除\n");

}
//显示一本书的信息
void print_the_book(book * p1)
{
printf("loading number:%d \n",p1->loading);
printf("name: ");
puts(p1->name);
printf(" \n");
printf("writer: ");
puts(p1->writer);
printf(" \n");
printf("identify:%d ***\n",p1->identify);
printf(" \n");
printf("pub: ");
puts(p1->pub);
printf(" \n");

printf("time: ");
puts(p1->time);
printf(" \n");
printf("price:%d ***\n",p1->price);
}
int chongfu(book * head,book * p)
{
book * p1=head->next;
int a=0;
while(p1!=NULL)
{
if(strcmp(p1->name,p->name)==0)
{
if(strcmp(p1->writer,p->writer)==0)
{
a=1;
break;
}
}
else
p1=p1->next;
}
return a;
}
//录入一些信息。。。。
void luru(book * head)
{
book * p1=head;
book * p2;

//寻找NULL前的那个点
while(p1->next!=NULL)
{
p1=p1->next;
}

int a;
do
{
p2=(book *)malloc(sizeof(book));
printf("输入书本信息\n");
printf("登录号\n");
fflush(stdin);
scanf("%d",&p2->loading);
printf("书名\n");
fflush(stdin);
gets(p2->name);
fflush(stdin);
printf("作者\n");
gets(p2->writer);
fflush(stdin);
printf("分类号\n");
scanf("%d",&p2->identify);
fflush(stdin);
printf("出版社\n");
gets(p2->pub);
fflush(stdin);
printf("出版时间\n");
gets(p2->time);
fflush(stdin);
printf("价格\n");
scanf("%d",&p2->price);
p2->next=NULL;
fflush(stdin);
//加入链表
if(chongfu(head,p2))
printf("录入信息重复\n");
else
{
p1->next=p2;
p1=p2;
}
printf("还想继续录入信息吗?\n(1:继续 0:停止)\n");

scanf("%d",&a);

}while(a==1);

}
void liulan(book * head)
{
book * p1=head->next;
int i=1;
while(p1!=NULL)
{
printf("*********第%d本书***********\n",i++);
print_the_book(p1);
p1=p1->next;

}
}
//查询。。。。
void chaxun(book * head)
{
printf("按书名查询还是按作者名查询?\n(1:按书名查询 0:按作者名查询)\n");
book * p=head->next;
int a;
scanf("%d",&a);
int num=0;
char cha[NAME_MAX];
switch(a)
{
case 1:
printf("输入书名:\n");
gets(cha);
while(p!=NULL)
{
if(strcmp(p->name,cha)==0)
{
num++;
print_the_book(p);
}
p=p->next;
}
break;
case 2:
printf("输入作者名:\n");
gets(cha);
while(p!=NULL)
{
if(strcmp(p->writer,cha)==0)
{
num++;
print_the_book(p);
}
p=p->next;
}
}
if(num==0)
printf("无符合书本\n");
}
//修改信息
void xiugai(book * head)
{
printf("输入需要修改书本的名称和作者:\n");
char name_book[NAME_MAX];
char writer_book[WRITER_MAX];
printf("书本名称:");
gets(name_book);
gets(writer_book);
book * p1=head->next;
int a=0;
while(p1!=NULL)
{
if(strcmp(p1->name,name_book)==0)
{
if(strcmp(p1->writer,writer_book)==0)
{
a=1;
break;
}
}
}
if(a==0)
printf("没有这本书。。。\n");
else
{
print_the_book(p1);
printf("输入新信息\n");
scanf("%d",&p1->loading);
gets(p1->name);
gets(p1->writer);
scanf("%d",&p1->identify);
gets(p1->pub);
gets(p1->time);
scanf("%d",&p1->price);
}

}
void main()
{
book * head;
head=(book *)malloc(sizeof(book));
Init(head);
int contin=1;
while(contin)
{
welcome();
printf("想进行哪项操作?\n");
int a;
scanf("%d",&a);
switch(a)
{
case 1:
luru(head);
break;
case 2:
liulan(head);
break;
case 3:
chaxun(head);
break;
case 4:
xiugai(head);
}
printf("继续使用图书馆还是退出?\n(1:continue 0:exit)\n");
scanf("%d",&contin);
}
}
相似回答