#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<bios.h>
#include<string.h>
typedef struct student /*学生籍贯结构体*/
{
char num[20];
char name[20];
char address[20];
}STUDENT;
typedef struct list /*学生籍贯结构体指针量*/
{
STUDENT stu;
struct list *next;
}STU;
typedef struct list node;
typedef node * link;
link createstu_list() /*创建学生籍贯链表*/
{
link q,head,pointer;
int i;
void save(link p);
textmode(2);
textcolor(YELLOW);
textbackground(BLUE);
window(1,2,59,25);
clrscr();
head=(link)malloc(sizeof(node));
if(head==NULL)
{
cprintf("memory mallocate failure!!\r\n");
}
else
{
cprintf("please input the information. [end]-finish\r\n");
textcolor(RED);
cprintf(" NO. Name Address\r\n");
pointer=head;
head->next=NULL;
textcolor(YELLOW);
fflush(stdin);
do
{
q=(link)malloc(sizeof(node));
q->next=NULL;
scanf("%s",q->stu.num);
if(strcmp(q->stu.num,"end")==0) break;
scanf("%s",q->stu.name);
scanf("%s",q->stu.address);
pointer->next=q;
pointer=pointer->next;
}
while(1);
}
save(head);
window(60,13,80,25);
textbackground(7);
clrscr();
cprintf("input a command:");
return head;
}
void free_list(link head)
{
link pointer;
while(head!=NULL)
{
pointer=head;
head=head->next;
free(pointer);
}
}
void save(link p) /*存盘*/
{
FILE *fp;
int i;
char buf[80*25*2+1];
gettext(1,1,80,25,buf);
window(1,2,59,25);
textcolor(YELLOW);
textbackground(BLUE);
textmode(2);
clrscr();
cprintf("Saving to database...\r\n");
sleep(1);
if((fp=fopen("D:\\stu jiguan.doc","w"))==NULL)
{
cprintf("can not open file!\r\n");
return;
}
fprintf(fp," The student Information about Address\n" );
fprintf(fp," NO.\t Name\t Address\n");
p=p->next;
while(p!=NULL)
{
fprintf(fp,"%10s\t%20s\t%20s\t\n",p->stu.num,p->stu.name,p->stu.address);
p=p->next;
}
fclose(fp);
cprintf("Saving Complete....\r\n");
sleep(1);
puttext(1,1,80,25,buf);
window(60,13,80,25);
textcolor(YELLOW);
textbackground(7);
clrscr();
cprintf("input a command:");
}
void GetInfor(link r) /*从磁盘获取数据*/
{
FILE *fp;
char buf[80*25*2+1];
link head;
link p,q;
char str1, str2, str3, str4, str5;
head=r;
gettext(1,1,80,25,buf);
clrscr();
textmode(2);
textcolor(YELLOW);
textbackground(BLUE);
window(1,2,59,25);
clrscr();
cprintf("Loading database...\r\n");
sleep(1);
if((fp=fopen("D:\\stu jigu.doc","r"))==NULL)
{
cprintf("can not open file!!\r\n");
return;
}
fscanf(fp,"%s %s %s",str1,str2,str3);
cprintf("%s %s %s",str1,str2,str3);
fscanf(fp,"%s %s",str4,str5);
cprintf("%s %s\r\n",str4,str5);
r=r->next;
q=r;
while(!feof(fp))
{
if(r!=NULL)
{ q=r;
fscanf(fp,"%s %s %s",p->stu.num,p->stu.name,p->stu.address);
r=r->next;
}
else
{
p=(link)malloc(sizeof(node));
fscanf(fp,"%s %s %s",p->stu.num,p->stu.name,p->stu.address);
if(p==NULL)
{
cprintf("Moemory allocate failure!!\r\n");
return;
}
p->next=NULL;
q->next=p;
q=q->next;
}
}
q->next=NULL;
p=r;
while(p!=NULL)
{
r=p->next;
free(p);
p=r;
}
r=head->next;
window(1,2,59,25);
clrscr();
cprintf("NO. Name address\r\n");
while(r->next!=NULL)
{
p=r;
cprintf("%s %s %s",r->stu.num,r->stu.name,r->stu.address);
cprintf("\r\n");
r=r->next;
}
free(r);
p->next=NULL;
gettext(1,1,80,25,buf);
fflush(stdin);
getch();
fclose(fp);
clrscr();
cprintf("Loading Complete....\r\n");
sleep(1);
puttext(1,1,80,25,buf);
window(60,13,80,25);
textbackground(7);
clrscr();
cprintf("input a command:");
}
void Output(link L)
{
link p;
int i;
clrscr();
textmode(2);
window(1,2,59,25);
textcolor(YELLOW);
textbackground(BLUE);
clrscr();
cprintf(" No. Name Address\r\n");
p=L->next;
while(p!=NULL)
{
cprintf("%5s %5s %5s",p->stu.num,p->stu.name,p->stu.address);
cprintf("\r\n");
p=p->next;
}
fflush(stdin);
getch();
window(60,13,80,25);
textbackground(7);
clrscr();
cprintf("input a command:");
}
void search_num(link L) /*以学号查找*/
{
int i;
char num[20];
char buf[80*25*2+1];
int exit=0;
gettext(1,1,80,25,buf);
window(60,13,80,25);
textbackground(7);
cprintf("\r\n");
cprintf("please input the number you want to search :\r\n");
cprintf("No.:");
scanf("%s",num);
textbackground(BLUE);
window(1,2,59,25);
clrscr();
cprintf("the result is:\r\n");
while(L!=NULL)
{
if(strcmp(L->stu.num,num)==0)
{
exit=1;
cprintf(" %s %s %s",L->stu.num,L->stu.name,L->stu.address);
cprintf("\r\n");
}
if(exit==1)
break;
L=L->next;
}
if(exit==0)
cprintf(" the student is not exit!\r\n");
fflush(stdin);
getch();
puttext(1,1,80,25,buf);
window(60,13,80,25);
textbackground(7);
clrscr();
cprintf("input a command:");
}
void search_name(link L) /*以姓名查找*/
{
int i;
char name[20];
char buf[80*25*2+1];
int exit=0;
gettext(1,1,80,25,buf);
window(60,13,80,25);
textbackground(7);
cprintf("\r\n");
cprintf("please input the name you want to search :");
cprintf("Name:");
scanf("%s",name);
L=L->next;
textbackground(BLUE);
window(1,2,59,25);
clrscr();
cprintf("the result is:\r\n");
while(L!=NULL)
{
if(strcmp(L->stu.name,name)==0)
{
exit=1;
cprintf(" %s %s %s",L->stu.num,L->stu.name,L->stu.address);
cprintf("\r\n");
}
L=L->next;
}
if(exit==0)
cprintf(" The student not exit!!\r\n");
fflush(stdin);
getch();
puttext(1,1,80,25,buf);
window(60,13,80,25);
textbackground(7);
clrscr();
cprintf("input a command:");
}
void search_address(link L) /*以籍贯查找*/
{
int i;
char add[20];
char buf[80*25*2+1];
int exit=0;
gettext(1,1,80,25,buf);
window(60,13,80,25);
textbackground(7);
cprintf("\r\nplease input the address you want to search:\r\n");
cprintf("Address:");
scanf("%s",add);
L=L->next;
window(1,2,59,25);
textbackground(BLUE);
clrscr();
cprintf("the result is:\r\n");
while(L!=NULL)
{
if(strcmp(L->stu.address,add)==0)
{
exit=1;
cprintf(" %s %s %s",L->stu.num,L->stu.name,L->stu.address);
cprintf("\r\n");
}
L=L->next;
}
if(exit==0)
cprintf(" The student is not exit!!\r
C语言编写的学生籍贯管理系统
需积分: 18 201 浏览量
2009-11-23
13:14:05
上传
评论 3
收藏 4KB RAR 举报
herofighter2008
- 粉丝: 12
- 资源: 22
最新资源
- 基于stm32f103c单片机+MPU6050+0.96英寸OLED显示屏双柄遥控器硬件(原理图+PCB)工程文件.zip
- 整理的关于少儿编程的学习路径,以及如何在小升初,初升高和大学充分的利用起来编程经验的优势
- 足球比赛结果统计表2006-2011年大约28W场比赛
- 基于PHP+mysql的社区交流系统(源代码)
- yolov5,SSD 可能使用到的一些代码
- 一键批量生成多层次文件夹结构,使用Python脚本实现嵌套文件夹批量生成
- 基于c51单片机+DS1302+DHT11温湿度模块+LCD1602显示的万年历硬件原理图+BOM+软件程源码序+仿真图.zip
- NSGA2的MATLAB代码
- Messagepassingtest_GCN_DGL.py
- Sh,Docker 运维好帮手,一招通过 sh 脚本批量快速启动和重启多个Docker 容器
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈