




已閱讀5頁,還剩30頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
#include #include #include #include #include #include #define YES 1#define NO 0typedef structint num;float math_score;float engl_score;float chin_score;float phy_score;float chem_score;double aver_score;double sum_score;char sex;StudentDate;/學(xué)生基本信息typedef struct studentchar name20;/學(xué)生姓名StudentDate one;/學(xué)生其他信息int rank;/成績排名struct student *next;Student, *List;Student *startCheck(void);/開始檢查Student *createListHead(void);/創(chuàng)建鏈表的頭void menu(void);/主菜單void sortList(Student *pHead);/排序鏈表void readListWithFile(Student *pHead, char *file_name);/從文件中讀取數(shù)據(jù),并保存在鏈表中void sorttList(Student *pHead);/排序鏈表int userChioce(Student *pHead);/用戶選擇int sortMenu(void);/打印選擇菜單void passwordCheck(void);/密碼檢測void correctWord(void);/修改密碼void addStudentInfo(Student *pHead);/向鏈表的末尾添加數(shù)據(jù)int scanMenu(void);/瀏覽菜單void findStudentInfo(Student *pHead);/查找學(xué)生信息void delStudentInfo(Student *pHead);/刪除某一個學(xué)生信息void alterStudentInfo(Student *pHead);/修改學(xué)生信息void saveList(Student *pHead);/將鏈表保存在文件里void printList(Student *pHead);/打印鏈表void statisStudentInfo(Student *pHead);/查看學(xué)生信息int statisMenu(void);/查看菜單void gotoxy(int x, int y);/改變光標位置函數(shù)void inputData(Student *pHead, Student *node);/輸入信息,并檢測是否合法int main(void)Student *pHead;HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);/得到窗口句柄SMALL_RECT rc = 0, 0, 94 - 1, 30 - 1 ; /Y位置,X位置,寬,高SetConsoleWindowInfo(hOut, true, &rc);/ 重置窗口位置和大小system(color 5B);/設(shè)置控制臺顏色pHead = startCheck();/讀取信息while (1)if (9 = userChioce(pHead) /按9時退出系統(tǒng)break;return 0;void menu(void)system(CLS);/清屏printf(nnnttttn);printf(tttt 學(xué)生成績統(tǒng)計系統(tǒng) n);printf(ttttn);printf(tttt 1 增加學(xué)生記錄 n);printf(ttttn);printf(tttt 2 刪除學(xué)生記錄 n);printf(ttttn);printf(tttt 3 修改學(xué)生記錄 n);printf(ttttn);printf(tttt 4 查找學(xué)生信息 n);printf(ttttn);printf(tttt 5 統(tǒng)計學(xué)生成績 n);printf(ttttn);printf(tttt 6 查看學(xué)生成績 n);printf(ttttn);printf(tttt 7 修改登陸密碼 n);printf(ttttn);printf(tttt 8 關(guān)于 n);printf(ttttn);printf(tttt 9 退出系統(tǒng) n);printf(ttttn);void gotoxy(int x, int y)/x為列坐標,y為行坐標COORD pos = x, y ;HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOut, pos);Student *startCheck(void)Student *pHead;FILE *fp1;char password20 = 123456;int i;if (fp1 = fopen(password.dat, rb) = NULL)/若密碼文件不存在,新建密碼文件fp1 = fopen(password.dat, wb);fwrite(password, 20, 1, fp1);fclose(fp1);printf(密碼初始化完成?。J密碼為:123456));passwordCheck();elsepasswordCheck();/讀條system(CLS);system(title 學(xué)生成績統(tǒng)計系統(tǒng)-載入中);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”printf(nnttt歡迎進入本系統(tǒng)!正在載入.);printf(nnnntttn);printf(ttt n);printf(tttn);gotoxy(26, 7);for ( i = 0; i next = NULL;return pHead;void readListWithFile(Student *pHead, char *file_name)FILE *fp;Student *p1, *p2;int count, rank = 0;StudentDate dat;char stu_name20;fp = fopen(file_name, r);if (fp = NULL)fp = fopen(file_name, w);fclose(fp);return;fseek(fp, 0L, 2);count = ftell(fp);p1 = pHead;fp = fopen(file_name, r);while (!feof(fp)p2 = (List)malloc(sizeof(Student);fscanf(fp, %d%s %c%f%f%f%f%fn, &p2-one.num, p2-name, &p2-one.sex, &p2-one.chin_score,&p2-one.math_score, &p2-one.engl_score, &p2-one.chem_score, &p2-one.phy_score);p2-one.sum_score = (double)(p2-one.chin_score + p2-one.chin_score + p2-one.engl_score +p2-one.chem_score + p2-one.phy_score);p2-one.aver_score = p2-one.sum_score / 5;p2-next = NULL;p1-next = p2;p1 = p2;if (ftell(fp) = count)break;/將鏈表排序,并初始化排名for (p1 = pHead-next; p1 != NULL; p1 = p1-next)for (p2 = p1-next; p2 != NULL; p2 = p2-next)if (p2-one.aver_score p1-one.aver_score)dat = p2-one;strcpy(stu_name, p2-name);p2-one = p1-one;strcpy(p2-name, p1-name);p1-one = dat;strcpy(p1-name, stu_name);p1-rank = +rank;fclose(fp);void sortList(Student *pHead)Student *p1, *p2;StudentDate dat;char stu_name20;int bum, count = 0, rank;system(title 學(xué)生成績統(tǒng)計系統(tǒng)-查看);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”bum = sortMenu();if (bum = 1)/按平均分高低排序for (p1 = pHead-next; p1 != NULL; p1 = p1-next)for (p2 = p1-next; p2 != NULL; p2 = p2-next)if (p2-one.aver_score p1-one.aver_score)dat = p2-one;rank = p2-rank;strcpy(stu_name, p2-name);p2-one = p1-one;p2-rank = p1-rank;strcpy(p2-name, p1-name);p1-one = dat;p1-rank = rank;strcpy(p1-name, stu_name);elseif (bum = 2)/按學(xué)號高低排序for (p1 = pHead-next; p1 != NULL; p1 = p1-next)for (p2 = p1-next; p2 != NULL; p2 = p2-next)if (p2-one.num one.num)dat = p2-one;rank = p2-rank;strcpy(stu_name, p2-name);p2-one = p1-one;p2-rank = p1-rank;strcpy(p2-name, p1-name);p1-one = dat;p1-rank = rank;strcpy(p1-name, stu_name);elseif (bum = 3)return;elsesortList(pHead);printList(pHead);void printList(Student *pHead)int count = 0;pHead = pHead-next;system(CLS);printf(tttt計科6班成績!);printf(nn );printf(n 學(xué)號 姓 名 性別語 文數(shù) 學(xué)英 語化 學(xué)物 理平均分總 分名次n);while (pHead) printf( n);printf( %-5d %-6s %c %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %-3dn, pHead-one.num,pHead-name, pHead-one.sex, pHead-one.chin_score, pHead-one.math_score,pHead-one.engl_score, pHead-one.chem_score, pHead-one.phy_score, pHead-one.aver_score, pHead-one.sum_score, pHead-rank);pHead = pHead-next;count+;printf( n);printf(ttt該班一共%d個人!, count);getch();int userChioce(Student *pHead)int bum;system(title 學(xué)生成績統(tǒng)計系統(tǒng)-主菜單);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”menu();printf(請按鍵選擇: );bum = (int)(getch() - 0);switch (bum)case 1:addStudentInfo(pHead);break;case 2:delStudentInfo(pHead);break;case 3:alterStudentInfo(pHead);break;case 4:findStudentInfo(pHead);break;case 5:statisStudentInfo(pHead);break;case 9:break;case 6:sortList(pHead);break;case 7:correctWord();break;case 8:MessageBox(NULL, TEXT(特性:進入系統(tǒng)需輸入密碼,可以修改密碼;展示學(xué)生信息時,以表格的方式呈現(xiàn);輸入學(xué)生信息時,不能輸入已存在的學(xué)號;以鏈表、文件為基礎(chǔ);作者:HappyBeers), TEXT(關(guān)于), MB_OK);break; default:break;return bum;int sortMenu(void)int bum;system(CLS);printf(nnn);printf(ttn);printf(tt 以什么方式查詢 ? n);printf(ttn);printf(tt 1 按成績的高低 n);printf(ttn);printf(tt 2 按學(xué)號的升次 n);printf(ttn);printf(tt 3 返回主菜單 n);printf(ttn);printf(請按鍵選擇:);bum = (int)(getch() - 0);system(CLS);return bum;void passwordCheck(void)char password20, inputword20;int i = 0, j = 0;char c = 0;FILE *fp = fopen(password.dat, rb);system(title 學(xué)生成績統(tǒng)計系統(tǒng)-密碼輸入);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”fread(password, 20, 1, fp);for (i = 0; i 5; i+)j = 0;printf(nnntt你還有%d次機會輸入正確密碼: , 3-i);printf(nnnntttn);printf(ttt n);printf(tttn);gotoxy(26, 8);while (c = getch() != 13 & j 0)putchar(b);putchar( );putchar(b);j-;elseif (isprint(c)/isprint為檢測C是否為可打印的函數(shù) putchar(*);inputwordj = c;j+;inputwordj = 0;if (strcmp(inputword, password) = 0)return;elsesystem(CLS);printf(ttt密碼輸入錯誤);if (5 = i)system(CLS);printf(nnntt你已浪費所有機會!程序即將退出!);Sleep(2000);exit(0);fclose(fp);system(CLS);return;void correctWord(void)char password20;FILE *fp;int i = 0;char c;system(title 學(xué)生成績統(tǒng)計系統(tǒng)-修改密碼);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”system(CLS);printf(nnnnttt請輸入新的密碼:);while (c = getch() != 13 & i 0)putchar(b);putchar( );putchar(b);i-;elseif (isprint(c)/isprint為檢測C是否為可打印的函數(shù) putchar(*);passwordi = c;i+;passwordi = 0;printf(nttt是否將密碼修改為? Y or N:, password);c = getch();if (c = Y | c = y)fp = fopen(password.dat, wb);fwrite(password, 20, 1, fp);fclose(fp);printf(nttt修改成功!n);elsereturn;getch();void addStudentInfo(Student *pHead)FILE *fp;Student *p1, *p2, *p3 = pHead;StudentDate dat;int judge = YES, rank = 0;char bum, stu_name20;system(title 學(xué)生成績統(tǒng)計系統(tǒng)-添加);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”fp = fopen(stud.dat, a);while (pHead-next)pHead = pHead-next;while (judge)p1 = (List)malloc(sizeof(Student);inputData(p3, p1);p1-next = NULL;pHead-next = p1;pHead = p1;fprintf(fp, %d %s %c %.1f %.1f %.1f %.1f %.1fn, p1-one.num, p1-name, p1-one.sex, p1-one.chin_score,p1-one.math_score, p1-one.engl_score, p1-one.chem_score, p1-one.phy_score);printf(是否繼續(xù)添加?(Y/N);bum = getch();if (bum = n | bum = N)break;/并交換排名for (p1 = p3-next; p1 != NULL; p1 = p1-next)for (p2 = p1-next; p2 != NULL; p2 = p2-next)if (p2-one.aver_score p1-one.aver_score)dat = p2-one;strcpy(stu_name, p2-name);p2-one = p1-one;strcpy(p2-name, p1-name);p1-one = dat;strcpy(p1-name, stu_name);p1-rank = +rank;fclose(fp);int scanMenu(void)int bum;system(CLS);printf(nnn);printf(ttn);printf(tt 以什么方式查詢 ? n);printf(ttn);printf(tt 1 按學(xué)生的學(xué)號 n);printf(ttn);printf(tt 2 按學(xué)生的姓名 n);printf(ttn);printf(tt 3 返回主菜單 n);printf(ttn);printf(請按鍵選擇:);bum = (int)(getch() - 0);system(CLS);return bum;void findStudentInfo(Student *pHead)int bum, count = 0;int num;char student_name20;pHead = pHead-next;system(title 學(xué)生成績統(tǒng)計系統(tǒng)-查找);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”bum = scanMenu();if (bum = 1)printf(請輸入學(xué)生的學(xué)號:);scanf(%d, &num);while (pHead)if (pHead-one.num = num)if (count = 0)printf(nttt已經(jīng)查到!n);printf(nnnn );printf(n 學(xué)號 姓 名 性別語 文數(shù) 學(xué)英 語化 學(xué)物 理平均分總 分名次n);count = 1;printf( n);printf( %-5d %-6s %c %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %-3dn, pHead-one.num,pHead-name, pHead-one.sex, pHead-one.chin_score, pHead-one.math_score,pHead-one.engl_score, pHead-one.chem_score, pHead-one.phy_score, pHead-one.aver_score, pHead-one.sum_score, pHead-rank);break;pHead = pHead-next;if (pHead = NULL)printf(nttt沒有該學(xué)生記錄!n);elseprintf( n);elseif (bum = 2)printf(請輸入學(xué)生姓名:);scanf(%s, student_name);while (pHead)if (strcmp(student_name, pHead-name) = 0)if (count = 0)printf(nttt已經(jīng)查到!n);printf(nnnn );printf(n 學(xué)號 姓 名 性別語 文數(shù) 學(xué)英 語化 學(xué)物 理平均分總 分名次n);count = 1;printf( n);printf( %-5d %-6s %c %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %-3dn, pHead-one.num,pHead-name, pHead-one.sex, pHead-one.chin_score, pHead-one.math_score,pHead-one.engl_score, pHead-one.chem_score, pHead-one.phy_score, pHead-one.aver_score, pHead-one.sum_score, pHead-rank);pHead = pHead-next;if (count = 0)printf(nttt沒有該學(xué)生記錄!);elseprintf( n);elseif (bum = 3)return;elsefindStudentInfo(pHead);getch();void delStudentInfo(Student *pHead)Student *p1, *p2 = pHead;int bum;int num, count = 0;char student_name20, c;system(title 學(xué)生成績統(tǒng)計系統(tǒng)-刪除);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”bum = scanMenu();if (bum = 1)p1 = pHead-next;printf(nttt請輸入要刪除學(xué)生的學(xué)號:);scanf(%d, &num);while (p1)if (p1-one.num = num)count = 1;printf(nttt刪除成功,刪除的學(xué)生學(xué)號為:%d, num);if (p1-next = NULL)pHead-next = NULL;break;elsepHead-next = p1-next;free(p1);p1 = pHead-next;elsepHead = pHead-next;p1 = pHead-next;elseif (bum = 2)p1 = pHead-next;printf(nttt請輸入要刪除的學(xué)生姓名:);scanf(%s, student_name);/統(tǒng)計一共有多少個學(xué)生while (p1)if (strcmp(p1-name, student_name) = 0)count+;p1 = p1-next;if (count 0)printf(nnnttt一共有%d個人的信息 全部刪除(Y) or 逐一刪除(N)?, count);/選擇全部刪除,還是逐一刪除c = getch();/全部刪除if (c = y | c = Y)p1 = pHead-next;while (p1)if (strcmp(p1-name, student_name) = 0)printf(nttt刪除成功,姓名為: %s, student_name);if (p1-next = NULL)pHead-next = NULL;break;elsepHead-next = p1-next;free(p1);p1 = pHead-next;elsepHead = pHead-next;p1 = pHead-next;else/逐一刪除p1 = pHead-next;while (p1)if (strcmp(p1-name,student_name) = 0)printf(n姓名:%s,學(xué)號:%d,性別:%c 是否刪除(y or n)?, p1-name, p1-one.num, p1-one.sex);c = getch();if (c = y| c = Y)if (p1-next = NULL)pHead-next = NULL;break;elsepHead-next = p1-next;free(p1);p1 = pHead-next;printf(成功!);elsepHead = pHead-next;p1 = pHead-next;elsepHead = pHead-next;p1 = pHead-next;elseif (bum = 3)return;elsedelStudentInfo(pHead);if (count = 0)printf(nttt沒有該學(xué)生信息!);elsesaveList(p2);getch();void saveList(Student *pHead)FILE *fp;fp = fopen(stud.dat, w+);pHead = pHead-next;while (pHead)fprintf(fp, %d %s %c %.1f %.1f %.1f %.1f %.1fn, pHead-one.num, pHead-name, pHead-one.sex, pHead-one.chin_score,pHead-one.math_score, pHead-one.engl_score, pHead-one.chem_score, pHead-one.phy_score);pHead = pHead-next;fclose(fp);void alterStudentInfo(Student *pHead)int bum, count = 0, j = 0;int num;char student_name20;Student *p1 = pHead-next;system(title 學(xué)生成績統(tǒng)計系統(tǒng)-修改);/將標題欄命名為“學(xué)生成績統(tǒng)計系統(tǒng)”bum = scanMenu();if (bum = 1)printf(nttt請輸入要修改學(xué)生的學(xué)號:);scanf(%d, &num);while (p1)j+;if (p1-one.
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 行政管理中公文撰寫的實踐性試題及答案
- 雙十一營銷企劃方案
- 行政心理學(xué)核心概念比較試題及答案
- 管理心理學(xué)幫助降低員工壓力的具體措施研究試題及答案
- 管理學(xué)應(yīng)用技能試題及答案
- 2025年簽訂合同邀請函模板
- 《2025項目管理服務(wù)合同》
- 2025餐飲技術(shù)轉(zhuǎn)讓合同范本
- 2025企業(yè)員工試用合同范本
- 2025租房合同簡化版
- 2024年公司網(wǎng)絡(luò)安全管理制度
- NCCN化療止吐指南教程
- 《小王子》講解+知識點+教案+課件
- 2025年甘肅蘭州市事業(yè)單位招考(868人)高頻重點提升(共500題)附帶答案詳解
- 生成式人工智能的教育應(yīng)用與展望-以ChatGPT 系統(tǒng)為例
- 妊娠期糖尿病病人的護理查房
- 幼兒園大班游戲中“一對一傾聽”的策略
- 醫(yī)院信息安全管理課件
- 傳染病處置規(guī)范與流程
- 拍賣合同范本大全(2025年)
- 中醫(yī)臨床診脈教學(xué)
評論
0/150
提交評論