C語(yǔ)言實(shí)現(xiàn)新生入學(xué)登記系統(tǒng)_第1頁(yè)
C語(yǔ)言實(shí)現(xiàn)新生入學(xué)登記系統(tǒng)_第2頁(yè)
C語(yǔ)言實(shí)現(xiàn)新生入學(xué)登記系統(tǒng)_第3頁(yè)
C語(yǔ)言實(shí)現(xiàn)新生入學(xué)登記系統(tǒng)_第4頁(yè)
C語(yǔ)言實(shí)現(xiàn)新生入學(xué)登記系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩10頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

第C語(yǔ)言實(shí)現(xiàn)新生入學(xué)登記系統(tǒng)printf("\n\n\n\n\n");

printf("\t|---------------歡迎進(jìn)入----------------|\n");

printf("\t|

新生入學(xué)登記系統(tǒng)

|\n");

printf("\t|

主菜單

|\n");

printf("\t|

1.錄入學(xué)生信息

|\n");

printf("\t|

2.瀏覽學(xué)生信息

|\n");

printf("\t|

3.查找學(xué)生信息

|\n");

printf("\t|

4.刪除學(xué)生信息

|\n");

printf("\t|

5.修改學(xué)生信息

|\n");

printf("\t|

6.新生入學(xué)排名

|\n");

printf("\t|

0.退出系統(tǒng)

|\n");

printf("\t|-----------------------------------------|\n");

printf("\n");

printf("\t\t請(qǐng)選擇(0-6):");

}

(4)BeginingAndEnding.h

#ifndefBEGININGANDENDING_H_INCLUDED

#defineBEGININGANDENDING_H_INCLUDED

//關(guān)于啟動(dòng)函數(shù)和結(jié)束函數(shù)

voidBegining();

voidEnding();

#endif//BEGININGANDENDING_H_INCLUDED

(5)BeginingAndEnding.c

#includestdio.h

#includeconio.h

//getc函數(shù)使用的頭文件

#include"system.h"

#include"AboutFiles.h"

#include"BeginingAndEnding.h"

#include"MyList.h"

voidBegining()

readInfoFromFile("studentList.txt");

voidEnding()

writeInfoToFile("studentList.txt");

}

(6)MyList.h

#ifndefMYLIST_H_INCLUDED

#defineMYLIST_H_INCLUDED

//關(guān)于鏈表的函數(shù)聲明

//創(chuàng)建節(jié)點(diǎn)

structNode*createNode(structstudentdata);

//插入節(jié)點(diǎn)

voidinsertNodeByHead(structstudentdata);

//指定位置刪除節(jié)點(diǎn)

voiddeleteAppointNode(char*studentId);

//查找功能

structNode*searchInfoByData(char*studentId);

//打印鏈表

voidprintList();

#endif//MYLIST_H_INCLUDED

(7)MyList.c

#includestdio.h

#includeconio.h

//getc函數(shù)使用的頭文件

#includewindows.h//Sleep函數(shù)使用的頭文件

#includestring.h//strcmp函數(shù)使用的頭文

#include"system.h"

#include"MyList.h"

structNode*studentList=NULL;

//鏈表的頭指針

//創(chuàng)建節(jié)點(diǎn)

structNode*createNode(structstudentstudentData)

structNode*newNode=(structNode*)malloc(sizeof(structNode));

if(newNode!=NULL)

{

newNode-studentData=studentData;

newNode-next=NULL;

}

returnnewNode;

//插入節(jié)點(diǎn)

voidinsertNodeByHead(structstudentdata)

structNode*newNode=createNode(data);

//表頭法插入,每次插入都將數(shù)據(jù)插入到頭節(jié)點(diǎn)的下一個(gè),先判斷頭節(jié)點(diǎn)是否為空,為空則新節(jié)點(diǎn)就是頭節(jié)點(diǎn),不為空,則插入在頭節(jié)點(diǎn)的下一個(gè)位置

if(studentList==NULL)

{

studentList=newNode;

}

else//不改變頭節(jié)點(diǎn)

{

newNode-next=studentList-next;

studentList-next=newNode;

}

//指定位置刪除節(jié)點(diǎn)(知道這個(gè)節(jié)點(diǎn)的前驅(qū)和后續(xù),然后進(jìn)行刪除)

voiddeleteAppointNode(char*studentId)

//將鏈表頭部設(shè)為指定位置,先判斷頭節(jié)點(diǎn)是否為空,為空則鏈表沒有數(shù)據(jù),無(wú)法刪除

//如果頭節(jié)點(diǎn)不為空,則設(shè)頭結(jié)點(diǎn)為指定位置,如果頭結(jié)點(diǎn)是所找的節(jié)點(diǎn),則刪除,如果不是,設(shè)頭結(jié)點(diǎn)的下一個(gè)為指定節(jié)點(diǎn),頭結(jié)點(diǎn)為指定節(jié)點(diǎn)的前驅(qū)節(jié)點(diǎn),一直向下查詢

//指定位置

structNode*posNode=studentList;

//指定位置的前面

structNode*posFrontNode=NULL;

//查找指定節(jié)點(diǎn)

if(posNode==NULL)

{

printf("數(shù)據(jù)為空無(wú)法刪除!\n");

return;

}

else

{

//姓名是字符串,不能直接比較,strcmp(),相等返回值為0,相同返回值為負(fù)數(shù)或者正數(shù)

if(strcmp(posNode-studentData.studentId,studentId)==0)

{

studentList=studentList-next;

free(posNode);

return;

}

else

{

posFrontNode=posNode;

posNode=posNode-next;

//posFrontNode=posNode;//!!

while(strcmp(posNode-studentData.studentId,studentId))

{

//繼續(xù)向下一個(gè)節(jié)點(diǎn)移動(dòng)

posFrontNode=posNode;

posNode=posFrontNode-next;

if(posNode==NULL)//找到了鏈表尾部,沒有找到數(shù)據(jù)

{

printf("未找到指定位置,無(wú)法刪除!");

return;

}

}

//查到到對(duì)應(yīng)數(shù)據(jù)后,進(jìn)行刪除,將該節(jié)點(diǎn)架空,然后釋放該節(jié)點(diǎn)的存儲(chǔ)單元

posFrontNode-next=posNode-next;

free(posNode);

return;

}

}

//查找功能

structNode*searchInfoByData(char*studentId)

structNode*pMove;

pMove=studentList;

if(pMove==NULL)//頭節(jié)點(diǎn)為空,鏈表為空

{

//printf("學(xué)生鏈表為空!\n");

returnpMove;

}

else

{

//查找到或者查找到鏈表最后,則結(jié)束循環(huán),返回查詢結(jié)果,結(jié)果為空,有兩種可能,一種是鏈表中沒有數(shù)據(jù),另一種是沒有查詢到

while(pMove!=NULL)

{

if(strcmp(pMove-studentData.studentId,studentId)==0)//找見

{

//printf("已查找到!\n");

returnpMove;

}

else

{

pMove=pMove-next;

}

}

//printf("未找到!\n");

returnpMove;

}

//打印鏈表

voidprintList()

structNode*pMove=studentList;

//涉及到展示數(shù)據(jù)

//表頭

if(pMove==NULL)

{

printf("Nostudentrecord!Pleaseadd.\n");

return;

}

else

{

printf("\t-------------------------------------------------------------------------------------\n");

printf("\t|%-10s|%-7s|%-4s|%-4s|%-12s|%-12s|%-12s|%-5s|\n","學(xué)號(hào)","姓名","性別","年齡","班級(jí)","專業(yè)","電話","入學(xué)成績(jī)");

printf("\t-------------------------------------------------------------------------------------\n");

while(pMove)

printf("\t|%-10s|%-7s|%-4s|%-4d|%-12s|%-12s|%-12s|%-8d|\n",STUDENT_DATA);

printf("\t-------------------------------------------------------------------------------------\n");

pMove=pMove-next;

}

}

printf("\n");

}

(8)AddStudent.h

#ifndefADDSTUDENT_H_INCLUDED

#defineADDSTUDENT_H_INCLUDED

voidAddStudent();

//錄入學(xué)生信息

#endif//ADDSTUDENT_H_INCLUDED

(9)AddStudent.c

#includestdio.h

#includeconio.h

//getc函數(shù)使用的頭文件

#includewindows.h//Sleep函數(shù)使用的頭文件

#includestring.h//strcmp函數(shù)使用的頭文

#include"AddStudent.h"

#include"system.h"

#include

"MyList.h"

//錄入學(xué)生信息

voidAddStudent()

structstudentstudentData;

structNode*isNull=NULL;

//接收查詢的返回值

intiFlagExist;

//保證不重復(fù)輸入

charcFlag;

intret;

//用來(lái)接收scanf的返回值,判斷輸入數(shù)據(jù)是否正確

system("cls");

printf("=================================================================\n");

printf("\t請(qǐng)輸入需要?jiǎng)h除的學(xué)生的學(xué)號(hào):");

gets(studentData.studentId);

pMove=searchInfoByData(studentData.studentId);

if(pMove)

//該學(xué)生存在,進(jìn)行刪除

{

//先對(duì)學(xué)生信息進(jìn)行展示

printf("\t-------------------------------------------------------------------------------------\n");

printf("\t|%-10s|%-7s|%-4s|%-4s|%-12s|%-12s|%-12s|%-5s|\n","學(xué)號(hào)","姓名","性別","年齡","班級(jí)","專業(yè)","電話","入學(xué)成績(jī)");

printf("\t-------------------------------------------------------------------------------------\n");

printf("\t|%-10s|%-7s|%-4s|%-4d|%-12s|%-12s|%-12s|%-8d|\n",STUDENT_DATA);

printf("\t-------------------------------------------------------------------------------------\n");

printf("\t已查找到該學(xué)生信息,是否刪除?(y/n)");

cFlag=getchar();

getchar();//吃掉緩沖區(qū)的空格

while(cFlag!='n'cFlag!='y')

{

printf("輸入有誤,請(qǐng)輸入‘y'或者‘n'!");

printf("\n請(qǐng)選擇是否輸入學(xué)生信息(y/n):");

cFlag=getchar();

getchar();

}

if(cFlag=='n')

return;

elseif(cFlag=='y')

{

deleteAppointNode(studentData.studentId);

printf("\t已刪除該學(xué)生信息!\n");

printf("\t刪除操作執(zhí)行結(jié)束!\n");

}

}

else//找到了鏈表的末尾,或者鏈表為空

{

printf("\t該學(xué)生不存在!無(wú)法執(zhí)行刪除操作\n");

}

}

(16)ModifyStudent.h

#ifndefMODIFYSTUDENT_H_INCLUDED

#defineMODIFYSTUDENT_H_INCLUDED

#include"system.h"

voidModifyStudent();//修改學(xué)生信息

voidShowModifyMenu();//展示修改選項(xiàng)菜單

voiddealSelection(structstudentstudentData,intselection,structNode*pMove);//處理用戶選擇的修改項(xiàng)

#endif//MODIFYSTUDENT_H_INCLUDED

(17)ModifyStudent.c

#includestdio.h

#includeconio.h

//getc函數(shù)使用的頭文件

#includewindows.h//Sleep函數(shù)使用的頭文件

#includestring.h//strcmp函數(shù)使用的頭文

#include"ModifyStudent.h"

#include"system.h"

#include"MyList.h"

//修改學(xué)生信息

voidModifyStudent()

structstudentstudentData;

structNode*pMove=NULL;//對(duì)學(xué)生信息查詢結(jié)果進(jìn)行保存

intselection;

//保存選擇信息

charisContinue='n';

//是否繼續(xù)進(jìn)行修改

system("cls");

printf("\n");

printf("\t================================================================\n");

if(studentList==NULL)

{

printf("學(xué)生登記為空,無(wú)法進(jìn)行成績(jī)排名\n");

return;

}

else//學(xué)生鏈表頭指針不為空,代表學(xué)生鏈表中存有學(xué)生信息

{

pMove=studentList;

//pMove指向鏈表的頭

//通過遍歷得到鏈表有多少個(gè)存儲(chǔ)單元

for(i=0;pMove!=NULL;i++)

{

pMove=pMove-next;

}

length=i;

printf("現(xiàn)有學(xué)生總?cè)藬?shù)為%d\n",length);

//動(dòng)態(tài)數(shù)組

stuRanking=(structstudentRanking*)malloc(length*sizeof(structstudentRanking));

if(stuRanking==NULL)

return;

//將需要輸出的學(xué)生信息復(fù)制到結(jié)構(gòu)體數(shù)組當(dāng)中

pMove=studentList;

for(j=0;jlength;j++)

{

strcpy(stuRanking[j].studentId,pMove-studentData.studentId);

strcpy(stuRanking[j].name,pMove-studentD);

strcpy(stuRanking[j].className,pMove-studentData.className);

stuRanking[j].score=pMove-studentData.score;

pMove=pMove-next;

}

//復(fù)制完成后,根據(jù)成績(jī)對(duì)學(xué)生進(jìn)行排序

sortByScore(stuRanking,length);

//根據(jù)排序結(jié)果,為每名同學(xué)添加排名信息

Ranking(stuRanking,length);

//展示排名

printf("排名結(jié)果如下:\n");

printf("\t-------------------------------------------------------\n");

printf("\t|%-10s|%-7s|%-12s|%-5s|%-5s|\n","學(xué)號(hào)","姓名","班級(jí)","入學(xué)成績(jī)","全級(jí)排名");

printf("\t-------------------------------------------------------\n");

for(j=0;jlength;j++)

{

printf("\t|%-10s|%-7s|%-12s|%-8d|%-8d|\n",STUDENT_RANKING);

printf("\t-------------------------------------------------------\n");

}

}

printf("輸出排名信息完畢!\n");

system("pause");

//通過成績(jī)對(duì)鏈表中的數(shù)據(jù)進(jìn)行排序

voidsortByScore(structstudentRanking*stuRanking,intlength)

//進(jìn)行冒泡排序,從大到小排序

inti,j;

structstudentRankingtemp;

for(i=0;ilength-1;i++)

{

for(j=0;j(length-i-1);j++)

{

if(stuRanking[j].scorestuRanking[j+1].score)//后一項(xiàng)比前一項(xiàng)大,則交換兩個(gè)存儲(chǔ)單元中的數(shù)據(jù),一輪排序下來(lái),最小項(xiàng)就位,在列表的最末尾

{

temp=*(stuRanking+j);

*(stuRanking+j)=*(stuRanking+j+1);

*(stuRanking+j+1)=temp;

}

}

}

voidRanking(structstudentRanking*stuRanking,intlength)

inti;

for(i=1;i=l

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論