主题:[原创]学生信息管理(c)---绝对原创(1)
这个简陋的程序是我在上一年的时间写的,因为没的经验,所以写的时间没有写注释,原本打算再修改,优化,再加上注释的,但是最终未能够实现,请大家见凉,如果大家对其中的某个实现感兴趣,请回帖指出。
另付:链表排序未实现,请大家不要使用这个功能
/***************************************************************************************************************************
*
* 文件名称: SRMSv100.c ( Student's Record Management System 1.0 )
*
* 文件标识: 学生档案管理系统
*
* 文件摘要: 学生档案管理系统源代码
*
* 当前版本: 1.0
*
* 作 者: Wilm.Gu
*
* 完成日期: 2004年5月16日
*
* 使用方法: 使用方法同Ms-Dos下的程序
*
* Alt+F: 打开文件菜单 . ALT+E: 打开编辑菜单.
*
* ALT+A: 显示版本信息.
*
* " ← , → , ↑ , ↓ ": 移动菜单栏 . Enter:确定.
*
***************************************************************************************************************************/
/***************************************************************************************************************************
*------------------------文件所包含的头文件 , 结构体定义 , 全局常量 , 变量定义 .--------------------------------------------
***************************************************************************************************************************/
#include<process.h>
#include<stdio.h>
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#include<string.h>
#define KEY_DOWN 0x5000
#define KEY_UP 0x4800
#define KEY_LEFT 0x4b00
#define KEY_RIGHT 0x4d00
#define KEY_ESC 0x011b
#define KEY_ALT_F 0x2100
#define KEY_ALT_E 0x1200
#define KEY_ALT_A 0x1e00
#define KEY_ALT_X 0x2d00
#define KEY_ENTER 0x1c0d
#define PAGE_UP 0x4900
#define PAGE_DOWN 0x5100
struct student
{
int stuNo;
char stuName[15];
char stuSex;
float stuMaths;
float stuChinese;
float stuEnglish;
struct student *prev;
struct student *next;
};
char *menu[]={"FILE","EDIT","ABOUT"};
char *red[]={"F","E","A"};
char *f[]={"Load ","New ","Save ","Write to ","Quit "};
char *e[]={"Insert ","Search ","Tall ","Delete ","All "};
char *s[]={"No ","Name "};
char *t[]={"No ","Name ","Maths ","Chinese ","English "};
char *d[]={"No ","Name "};
FILE *fp;
int menuLine=0,pageNumber=0,pageCount,maxPage;
char fileName[30];
char buf[16*10*2],buf1[16*2],buf2[16*2],buf3[4092],buf4[16*2];
struct student *nHead,*nTail,*nTemp,*nCurrent;
/***************************************************************************************************************************
*
* 函数名称: void box()
*
* 函数参数: int startx , int starty , int hight , int width .
*
* 参数说明:
*
* 函数功能: 画一个左上角坐标为(startx,starty),高为hight,宽为width的矩形.
*
* 函数说明: 0xda: "┌" ,0xc4: "--" ,0xbf: "┐" ,0xb3: "│" ,0xc0: "└" ,0xd9: "┘" .
*
***************************************************************************************************************************/
void box(int startx,int starty,int hight,int width)
{ int i;
gotoxy(startx,starty);
putch(0xda);
for(i=startx+1;i<width;i++)
putch(0xc4);
putch(0xbf);
for(i=starty+1;i<hight;i++)
{
gotoxy(startx,i);
putch(0xb3);
gotoxy(width,i);
putch(0xb3);
}
gotoxy(startx+1,width);
putch(0xc0);
for(i=startx+1;i<width;i++)
putch(0xc4);
putch(0xd9);
return;
}
void showPageData(int num)
{
int count=1,nowPage=1;
textbackground(3);
textcolor(15);
window(1,3,80,21);
clrscr();
window(1,3,80,21);
textcolor(15);
gotoxy(1,1);
cprintf("No Name Sex Maths Chinese English\n");
nCurrent=nHead;
do
{
count++;
if(count>19)
{
count=count%19;
nowPage++;
if(count==1){count++;}
}
if(nowPage==num)
{
gotoxy(1,count);cprintf("%d",nCurrent->stuNo);
gotoxy(11,count);cprintf("%s",nCurrent->stuName);
gotoxy(26,count);cprintf("%c",nCurrent->stuSex);
gotoxy(37,count);cprintf("%f",nCurrent->stuMaths);
gotoxy(50,count);cprintf("%f",nCurrent->stuChinese);
gotoxy(65,count);cprintf("%f",nCurrent->stuEnglish);
window(1,3,80,25);
gotoxy(1,23);clreol();cprintf(" Page Number: %d",pageCount);
}
if(nowPage>num)
{ return; }
nCurrent=nCurrent->next;
}while(nCurrent!=NULL);
}
void showPage(int num)
{
if(nHead==NULL)
{ return; }
else
{
if(pageCount==1&&num==1)
{ return; }
if(pageCount==maxPage&&num==2)
{ return; }
if(num==1)
{
showPageData(--pageCount);
return;
}
if(num==2)
{
showPageData(++pageCount);
return;
}
}
}
void recordList(void)
{
int printLine=2;
window(1,3,80,21);
gotoxy(1,1);
cprintf("No Name Sex Maths Chinese English\n");
nCurrent=nHead;
do
{
if(printLine>19)
{
printLine=printLine%19;
textbackground(3);
window(1,3,80,21);
clrscr();
gotoxy(1,1);
cprintf("No Name Sex Maths Chinese English\n");
printLine+=1;
}
gotoxy(1,printLine);cprintf("%d",nCurrent->stuNo);
gotoxy(11,printLine);cprintf("%s",nCurrent->stuName);
gotoxy(26,printLine);cprintf("%c",nCurrent->stuSex);
gotoxy(37,printLine);cprintf("%f",nCurrent->stuMaths);
gotoxy(50,printLine);cprintf("%f",nCurrent->stuChinese);
gotoxy(65,printLine++);cprintf("%f",nCurrent->stuEnglish);
window(1,3,80,25);
gotoxy(1,23);clreol();cprintf(" Page Number: %d",pageCount);
nCurrent=nCurrent->next;
}while(nCurrent!=NULL);
}
void showPageCount(void)
{
int count=0;
nCurrent=nHead;
do
{
count++;
if(count>18)
{
count=count%18;
++pageCount;
}
nCurrent=nCurrent->next;
}while(nCurrent!=NULL);
maxPage=pageCount;
}
void show(int i)
{
textbackground(3);
window(1,3,80,14);
clrscr();
textbackground(15);
textcolor(0);
puttext(1,3,80,21,buf3);
window(20,10,50,13);
clreol();
box(1,1,3,31);
gotoxy(10,1);
switch(i)
{
case 1 : cprintf("Load File");break;
case 2 : cprintf("Save File");break;
case 3 : gotoxy(2,1);cprintf("Insert Data");break;
case 4 : gotoxy(2,1);cprintf("Search Data");break;
case 5 : gotoxy(2,1);cprintf("Delete Data");break;
default: exit(0); /* 错误退出 */
}
gotoxy(2,2);
cprintf(" ");
gotoxy(2,2);
}
另付:链表排序未实现,请大家不要使用这个功能
/***************************************************************************************************************************
*
* 文件名称: SRMSv100.c ( Student's Record Management System 1.0 )
*
* 文件标识: 学生档案管理系统
*
* 文件摘要: 学生档案管理系统源代码
*
* 当前版本: 1.0
*
* 作 者: Wilm.Gu
*
* 完成日期: 2004年5月16日
*
* 使用方法: 使用方法同Ms-Dos下的程序
*
* Alt+F: 打开文件菜单 . ALT+E: 打开编辑菜单.
*
* ALT+A: 显示版本信息.
*
* " ← , → , ↑ , ↓ ": 移动菜单栏 . Enter:确定.
*
***************************************************************************************************************************/
/***************************************************************************************************************************
*------------------------文件所包含的头文件 , 结构体定义 , 全局常量 , 变量定义 .--------------------------------------------
***************************************************************************************************************************/
#include<process.h>
#include<stdio.h>
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#include<string.h>
#define KEY_DOWN 0x5000
#define KEY_UP 0x4800
#define KEY_LEFT 0x4b00
#define KEY_RIGHT 0x4d00
#define KEY_ESC 0x011b
#define KEY_ALT_F 0x2100
#define KEY_ALT_E 0x1200
#define KEY_ALT_A 0x1e00
#define KEY_ALT_X 0x2d00
#define KEY_ENTER 0x1c0d
#define PAGE_UP 0x4900
#define PAGE_DOWN 0x5100
struct student
{
int stuNo;
char stuName[15];
char stuSex;
float stuMaths;
float stuChinese;
float stuEnglish;
struct student *prev;
struct student *next;
};
char *menu[]={"FILE","EDIT","ABOUT"};
char *red[]={"F","E","A"};
char *f[]={"Load ","New ","Save ","Write to ","Quit "};
char *e[]={"Insert ","Search ","Tall ","Delete ","All "};
char *s[]={"No ","Name "};
char *t[]={"No ","Name ","Maths ","Chinese ","English "};
char *d[]={"No ","Name "};
FILE *fp;
int menuLine=0,pageNumber=0,pageCount,maxPage;
char fileName[30];
char buf[16*10*2],buf1[16*2],buf2[16*2],buf3[4092],buf4[16*2];
struct student *nHead,*nTail,*nTemp,*nCurrent;
/***************************************************************************************************************************
*
* 函数名称: void box()
*
* 函数参数: int startx , int starty , int hight , int width .
*
* 参数说明:
*
* 函数功能: 画一个左上角坐标为(startx,starty),高为hight,宽为width的矩形.
*
* 函数说明: 0xda: "┌" ,0xc4: "--" ,0xbf: "┐" ,0xb3: "│" ,0xc0: "└" ,0xd9: "┘" .
*
***************************************************************************************************************************/
void box(int startx,int starty,int hight,int width)
{ int i;
gotoxy(startx,starty);
putch(0xda);
for(i=startx+1;i<width;i++)
putch(0xc4);
putch(0xbf);
for(i=starty+1;i<hight;i++)
{
gotoxy(startx,i);
putch(0xb3);
gotoxy(width,i);
putch(0xb3);
}
gotoxy(startx+1,width);
putch(0xc0);
for(i=startx+1;i<width;i++)
putch(0xc4);
putch(0xd9);
return;
}
void showPageData(int num)
{
int count=1,nowPage=1;
textbackground(3);
textcolor(15);
window(1,3,80,21);
clrscr();
window(1,3,80,21);
textcolor(15);
gotoxy(1,1);
cprintf("No Name Sex Maths Chinese English\n");
nCurrent=nHead;
do
{
count++;
if(count>19)
{
count=count%19;
nowPage++;
if(count==1){count++;}
}
if(nowPage==num)
{
gotoxy(1,count);cprintf("%d",nCurrent->stuNo);
gotoxy(11,count);cprintf("%s",nCurrent->stuName);
gotoxy(26,count);cprintf("%c",nCurrent->stuSex);
gotoxy(37,count);cprintf("%f",nCurrent->stuMaths);
gotoxy(50,count);cprintf("%f",nCurrent->stuChinese);
gotoxy(65,count);cprintf("%f",nCurrent->stuEnglish);
window(1,3,80,25);
gotoxy(1,23);clreol();cprintf(" Page Number: %d",pageCount);
}
if(nowPage>num)
{ return; }
nCurrent=nCurrent->next;
}while(nCurrent!=NULL);
}
void showPage(int num)
{
if(nHead==NULL)
{ return; }
else
{
if(pageCount==1&&num==1)
{ return; }
if(pageCount==maxPage&&num==2)
{ return; }
if(num==1)
{
showPageData(--pageCount);
return;
}
if(num==2)
{
showPageData(++pageCount);
return;
}
}
}
void recordList(void)
{
int printLine=2;
window(1,3,80,21);
gotoxy(1,1);
cprintf("No Name Sex Maths Chinese English\n");
nCurrent=nHead;
do
{
if(printLine>19)
{
printLine=printLine%19;
textbackground(3);
window(1,3,80,21);
clrscr();
gotoxy(1,1);
cprintf("No Name Sex Maths Chinese English\n");
printLine+=1;
}
gotoxy(1,printLine);cprintf("%d",nCurrent->stuNo);
gotoxy(11,printLine);cprintf("%s",nCurrent->stuName);
gotoxy(26,printLine);cprintf("%c",nCurrent->stuSex);
gotoxy(37,printLine);cprintf("%f",nCurrent->stuMaths);
gotoxy(50,printLine);cprintf("%f",nCurrent->stuChinese);
gotoxy(65,printLine++);cprintf("%f",nCurrent->stuEnglish);
window(1,3,80,25);
gotoxy(1,23);clreol();cprintf(" Page Number: %d",pageCount);
nCurrent=nCurrent->next;
}while(nCurrent!=NULL);
}
void showPageCount(void)
{
int count=0;
nCurrent=nHead;
do
{
count++;
if(count>18)
{
count=count%18;
++pageCount;
}
nCurrent=nCurrent->next;
}while(nCurrent!=NULL);
maxPage=pageCount;
}
void show(int i)
{
textbackground(3);
window(1,3,80,14);
clrscr();
textbackground(15);
textcolor(0);
puttext(1,3,80,21,buf3);
window(20,10,50,13);
clreol();
box(1,1,3,31);
gotoxy(10,1);
switch(i)
{
case 1 : cprintf("Load File");break;
case 2 : cprintf("Save File");break;
case 3 : gotoxy(2,1);cprintf("Insert Data");break;
case 4 : gotoxy(2,1);cprintf("Search Data");break;
case 5 : gotoxy(2,1);cprintf("Delete Data");break;
default: exit(0); /* 错误退出 */
}
gotoxy(2,2);
cprintf(" ");
gotoxy(2,2);
}