資源簡介
圖書學生管理系統
void Append_book(SqList_B &book)
{//批量添加圖書
int i,j,k,pos;
char filename[50];
BElemType e;
FILE *fp;
printf("\t\t----------新添一批圖書------------\n");
printf("\t請輸入新書文件全名:");
gets(filename);
fp=fopen(filename,"r");
if(fp)
{ k=book.length;
pos=k+1;
while(!feof(fp))
{fscanf(fp,"%s %s %s %s %d %d %d %d %d",e.bookno,e.bookname,e.author,
e.publisher,&e.totalnum,&e.borrownum,&e.pubday.year,&e.pubday.month,&e.pubday.day);
//e.borrownum=e.totalnum;
ListInsert_BSq(book,++k,e);
}
fclose(fp);
printf("-----------新添加以下圖書-------------\n");
Output_Book(book,pos);
}
else printf("沒有找到這個文件\n");
}

代碼片段和文件信息
#include“stdio.h“
#include“string.h“
#include
#include
#include
#include
#define?OK?1
#define?ERROR?0
#define?OVERFLOW?-2
#define?TRUE?1
#define?FALSE?0
typedef?int?Status;
typedef?struct?{
????int?year?month?day;?
}?DATE;
//-?-?-?-?-線性表的動態分配順序存儲結構-?-?-?-?-
#define?LIST_INIT_SIZE?400??//線性表存儲空間的初始分配
#define?LISTINCREMENT?50??//線性表存儲空間的分配增量
void?pressanykey()?//顯示“敲任意鍵繼續”并等待
{
????printf(“=======敲任意鍵繼續=======“);
????getch();
????fflush(stdin);//用來清空輸入緩存,以便不影響后面輸入的東西
????printf(“\n\n“);
}
int?index(char?*s1?char?*s2)?//在s1[]中查找串s2[],找到返回TRUE,否則返回FALSE
{
????int?i=0?j=0?k;
????int?len1?len2;
????len1?=?strlen(s1);
????len2?=?strlen(s2);
?????i?=?0;
????while?(i?<=?len1?-?len2)?{
????????k?=?i;
????????j?=?0;
????????while?(*(s1?+?k)?==?*(s2?+?j)?&&?j?????????????k++?j++;
????????if?(j?==?len2)?return?TRUE;
????????i++;
????}
????return?FALSE;
}
DATE?Get_Sys_Time()?//返回當前系統時間
{
????struct?tm?today;?//存放時間的結構體
????time_t?one;?//存放時間的類型
????DATE?now;
????one?=?time(&one);?//獲得系統時間
????today?=?*(gmtime(&one));?//將time_t格式系統時間轉為struct?tm格式
????now.year?=?today.tm_yday?-?100?+?2000;?//2011年返回111
????now.month?=?today.tm_mon?+?1;?//9月返回8;
????now.day?=?today.tm_mday;
????return?now;
}
//-------------學生管理
typedef?struct?student?//?學生結構體
{
????char?studentno[13];?//學號
????char?studentname[16];?//姓名
????char?studentmajor[18];?//專業
????char?studentclass[8];?//班級
????char?studentmobile[20];?//手機
}?ElemType_Stu;
typedef?ElemType_Stu?SElemType;
typedef?struct?//定義學生信息順序表
{
????SElemType?*elem;?//存儲空間基址
????int?length;?//當前長度
????int?listsize;?//當前分配的存儲容量
}?SqList_S;
Status?InitList_SSq(SqList_S?&L)?{//構造一個空的線性表L
????L.elem?=?(SElemType*)?malloc(LIST_INIT_SIZE?*?sizeof?(SElemType));
????if?(!L.elem)exit(OVERFLOW);?//存儲分配失敗
????L.length?=?0;?//空表長度為0
????L.listsize?=?LIST_INIT_SIZE;?//初始存儲容量
????return?OK;
}//InitList_SSq
Status?DestroyList_SSq(SqList_S?&L)?{//銷毀一個線性表L
????free(L.elem);
????L.length?=?0;
????L.listsize?=?0;
????return?OK;
}
int?ListLength_SSq(SqList_S?L)?{
????return?L.length;
}
Status?ListInsert_SSq(SqList_S?&L?int?i?SElemType?e)?//在線性表的第i個元素前插入數據e
{
????SElemType?*p?*q?*newbase;
????if?(i?1?||?i?>?L.length?+?1)?return?ERROR;
????if?(L.length?>=?L.listsize)?{
????????newbase?=?(SElemType*)?realloc(L.elem?(L.listsize?+?LISTINCREMENT)?*?sizeof?(SElemType));
????????if?(!newbase)exit(OVERFLOW);?//存儲分配失敗
????????L.elem?=?newbase;?//新地址
????????L.listsize?+=?LISTINCREMENT;?//增加存儲容量
????}
????q?=?&(L.elem[i?-?1]);?//q為插入位置
????if?(L.length?>=?1)
????????for?(p?=?&(L.elem[L.length?-?1]);?p?>=?q;?--p)
????????????*(p?+?1)?=?*p;?//插入點后數據都往后挪
????*q?=?e;?//插入e
????++L.length;?//表長增1
????return?OK;
}
Status?ListDelete_SSq(SqList_S?&L?int?i?SElemType?&e)?{//在順序線性表L中刪除第i個元素,并用e返回其值
????//i的合法值為1≤i≤ListLength_Sq(L)
????SElemType?*p?*q;
????if?((i?1)?||?(i?>?L.length))return?ERROR;?//i值不合法
????p?=?&(L.elem[i?-?1]);?//p為被刪除元素的位置
????e?=?*p;?//被刪除元素的值賦給e
????q?=?L.elem?+?L.length?-?1;?/
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????144??2015-01-15?23:01??Application_1\.dep.inc
?????文件???????1989??2015-01-15?22:02??Application_1\append_book.txt
?????文件???????2528??2015-01-15?22:02??Application_1\append_stu.txt
?????文件???????4926??2015-01-15?22:02??Application_1\book.txt
?????文件????????534??2015-01-15?22:02??Application_1\borrow.txt
?????文件??????74762??2015-01-15?23:01??Application_1\build\Debug\MinGW-Windows\Stu_Book.o
?????文件?????????52??2015-01-15?23:01??Application_1\build\Debug\MinGW-Windows\Stu_Book.o.d
?????文件??????85053??2015-01-15?23:01??Application_1\dist\Debug\MinGW-Windows\application_1.exe
?????文件???????2215??2015-01-15?22:24??Application_1\Makefile
?????文件???????1990??2015-01-15?22:26??Application_1\nbproject\configurations.xm
?????文件???????1399??2015-01-15?22:26??Application_1\nbproject\Makefile-Debug.mk
?????文件???????3756??2015-01-15?22:26??Application_1\nbproject\Makefile-impl.mk
?????文件???????1416??2015-01-15?22:26??Application_1\nbproject\Makefile-Release.mk
?????文件???????1296??2015-01-15?22:26??Application_1\nbproject\Package-Debug.bash
?????文件???????1306??2015-01-15?22:26??Application_1\nbproject\Package-Release.bash
?????文件???????1160??2015-01-15?22:26??Application_1\nbproject\private\configurations.xm
?????文件??????????0??2015-01-15?22:24??Application_1\nbproject\private\private.properties
?????文件????????211??2015-01-15?23:02??Application_1\nbproject\private\private.xm
?????文件??????????0??2015-01-15?22:24??Application_1\nbproject\project.properties
?????文件????????584??2015-01-15?23:02??Application_1\nbproject\project.xm
?????文件???????8304??2015-01-15?22:28??Application_1\student1.txt
?????文件??????50642??2015-01-15?23:01??Application_1\Stu_Book.cpp
?????目錄??????????0??2015-01-15?23:01??Application_1\build\Debug\MinGW-Windows
?????目錄??????????0??2015-01-15?23:01??Application_1\dist\Debug\MinGW-Windows
?????目錄??????????0??2015-01-15?22:51??Application_1\build\Debug
?????目錄??????????0??2015-01-15?22:25??Application_1\dist\Debug
?????目錄??????????0??2015-01-15?23:02??Application_1\nbproject\private
?????目錄??????????0??2015-01-15?22:51??Application_1\build
?????目錄??????????0??2015-01-15?22:25??Application_1\dist
?????目錄??????????0??2015-01-15?22:26??Application_1\nbproject
............此處省略4個文件信息
- 上一篇:SQL Server綜合性實驗報告
- 下一篇:報刊訂閱數據庫
評論
共有 條評論