資源簡介
早期寫的在linux下編寫的C程序,作為鞏固C語言的實踐項目。

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?User?10??????????????????//用戶名最大寬度
#define?Password?10??????????????//密碼最大寬度
#define?Hight?24?????????????????//控制臺高度
#define?Width?80?????????????????//控制臺寬度
#define?DefaultUser?“admin“??????//默認的用戶名
#define?DefaultPassword?“123456“?//默認的用戶密碼
#define?StudentName?20???????????//學生姓名最大長度
#define?OnePageNum?8?????????????//一頁顯示信息條數
#define?MARKLEN?(Width-2-StudentName-8)/8??????//除學號和姓名外其他項目所占長度
#define?FILEADDR?“data.txt“??????//默認文件名
#define?FILE_NAME_NUM?8??????????//文件名長度
int?WrongTimes?=?3;?????//允許登錄輸錯密碼次數
int?IsSaved?=?0;????????//記錄是否保存0為已保存
int?student_num?=?0;????//學生實際人數
int?maxnum?=?0;?????????//最大學號
int?sys_year?=?0;???????//系統時間?年
int?sys_mon?=?0;????????//系統時間?月
int?sys_day?=?0;????????//系統時間?日
typedef?struct?del_node???//存放缺漏的學號
{
int?Sno;
struct?del_node?*next;
}del_Node?*del_list?*del_pointer;
typedef?struct?date_node
{
int?Year;?????????//年
int?Month;????????//月
int?Day;??????????//日
}m_date;
typedef?struct?student_node
{
int?Sno;??????????????//學號
char?Name[20];????????//姓名
m_date?birthday;??????//生日
float?score[5];???????//五門成績:語文數學英語物理化學
}student_info;
typedef?struct?node??????????//學生信息的數據結構
{
student_info?data;
struct?node*?next;????//指向下一結點
}Node?*lklist?*pointer;
pointer?p?=?NULLq;????//p為尾巴結點用于添加???q用于其他
lklist?head?=?NULL;????//學生數據頭結點
del_list?del_head?=?NULL;??//缺漏學號鏈表頭結點
del_pointer?del_last?=?NULL;//缺漏學號鏈表尾結點
/************************
功能:添加新的結點到鏈表中
參數:lklist?head鏈表頭結點
?????lklist?*last鏈表尾結點指針
?????其他學生結點信息
返回:鏈表頭結點
************************/
lklist?add(lklist?head?lklist?*last?student_info?data)
{
if(head?==?NULL)???//如果鏈表為空
{
head?=?(Node?*)malloc(sizeof(Node));
*last?=?head;
head->data.Sno?=?0;
head->next?=?NULL;
}
q?=?(Node?*)malloc(sizeof(Node));
q->data?=?data;
if?(q->data.Sno?>?maxnum)
maxnum?=?q->data.Sno;??//記錄最大學號
(*last)->next=q;
*last=q;
(*last)->next?=?NULL;
return?head;
}
/************************
功能:添加缺漏的學號
參數:lklist?head鏈表頭結點
?????lklist?*last鏈表尾結點指針
?????int?sno?學號
返回:鏈表頭結點
************************/
del_list?add_del_sno(del_list?head?del_list?*last?int?sno)
{
del_pointer?x;
if(head?==?NULL)???//如果鏈表為空
{
head?=?(del_Node?*)malloc(sizeof(del_Node));
head->Sno?=?0;
*last?=?head;
head->next?=?NULL;
}
x?=?(del_Node?*)malloc(sizeof(del_Node));
x->Sno?=?sno;
head->Sno?=?head->Sno?+?1;
(*last)->next?=?x;
*last?=?x;
(*last)->next?=?NULL;
return?head;
}
/************************
功能:清空鏈表結點
參數:lklist?head鏈表頭結點
?????lklist?*last鏈表尾結點指針
返回:無
************************/
void?del(lklist?head?lklist?*last)
{
if?(head?==?NULL?||?head->next?==?NULL)
return;
while?(head->next)
{
q?=?head->next;
head->next?=?q->next;
free(q);
}
*last?=?head;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????624??2009-07-14?16:00??student_info\data.txt
?????文件??????37178??2009-07-16?14:14??student_info\main
?????文件??????50610??2009-07-16?14:02??student_info\main.c
?????文件????1184768??2009-07-16?11:21??student_info\學生信息管理系統項目說明文檔.doc
?????目錄??????????0??2009-12-26?17:07??student_info
-----------?---------??----------?-----??----
??????????????1273180????????????????????5
- 上一篇:300個C語言程序范例
- 下一篇:Ch376操作鼠標鍵盤
評論
共有 條評論