【正文】
編 程 實 習 報 告 (2009屆)題 目: 用字符串指針實現(xiàn)學生成績管理系統(tǒng)姓 名: 楊宇超 學 號: 09061109 學 院: 自動化學院 班 級: 09063011 指導教師: 席旭剛 高云園2022年8月20日 2011年7月5日摘要:本文介紹運用C語言中單用字符串指針實現(xiàn)一個學生信息管理工具軟件,主要功能有:add、show、sort、Delete。程序由七個子函數(shù)(creat、edit、extra、imdelete、print、save、)和一個主函數(shù)(main)組成。關鍵字:C語言、用字符串指針、學生信息一、任務要求(用字符串指針實現(xiàn)學生成績管理系統(tǒng)。完成函數(shù)void DeleteStudent(char*** students,int*** marks)。void SortClass(char** students,int** marks)。void ShowClass(char** students,int** marks)。void EditMarks(char** students,int** marks)。二、詳細設計(分析各函數(shù)的功能,設計各函數(shù)的處理過程及其流程圖)void InsertStudent(char*** students,int*** marks)。插入學生姓名 基本想法:先讀取學生姓名,判斷指針是否為空,為空則建立內(nèi)存。否則再開拓新的內(nèi)存空間,然后將讀取的學生與名單一一比較,若相同,則顯示已存在該學生,若沒有,則開拓內(nèi)存給新到的學生,并對名單進行排序,最后釋放內(nèi)存。void DeleteStudent(char*** students,int*** marks)。刪除學生信息基本想法:先讀取要刪除的學生姓名,將讀入的學生姓名與已存在的學生進行比較,如相同,記住該學生所在位置,判斷該學生下一個是否為空,若為空,就可以直接把該學生內(nèi)存釋放掉。若不是,則用一個while 將后面的所有學生向前移一位 直到NULL,再釋放最后的內(nèi)存,最后再釋放學生姓名的那個內(nèi)存void SortClass(char** students,int** marks)。 排序 根據(jù)學生姓名基本想法:采用冒泡法來進行排序。N次排序 先進行n1次比大小,找到最小的,與第一個交換,再進行n2次。void ShowClass(char** students,int** marks)。 顯示所有學生信息基本想法:直接用printf 輸出,void EditMarks(char** students,int** marks)。 編輯學生成績基本想法:先讀取要編輯的學生姓名,然后與所有的學生姓名進行比較,判斷是否在名單內(nèi),若不在,就輸出不在,否則 就再讀取該學生的5個成績到 marks 三、編碼實現(xiàn)include include include void InsertStudent(char*** students,int*** marks)。void DeleteStudent(char*** students,int*** marks)。void SortClass(char** students,int** marks)。void ShowClass(char** students,int** marks)。void EditMarks(char** students,int** marks)。char* ReadLine()。define merror(a) {printf(memory allocation error %d\n,a)。exit(1)。}/* function main */int main(){char** students = NULL。int** marks = NULL。char line[100]。int menu。while(1) {printf(Enter (1) to Add a Student to Class List\n (2) to Delete a Student from Class List\n (3) to show Class List\n (4) to Edit marks of a Student\n (5) to Quit\n)。fflush(stdout)。gets(line)。if (sscanf(line,%d,amp。menu) != 1){ printf(incorrect entry)。 continue。}if (menu 1 || menu 5){ printf(incorrect selection)。 continue。}if (menu == 1) InsertStudent(amp。students,amp。marks)。else if (menu == 2) DeleteStudent(amp。students,amp。marks)。else if (menu == 3) ShowClass(students,marks)。else if (menu == 4) EditMarks(students,marks)。else break。}/*endwhile*/return 0。//read here}/*end main*//* function InsertStudent *//*This function prompts the user to enter a new student name.The precise form of the prompt is Enter Student Name to be added to Class List:Then this function reads the name from standard input.But it must be able to read any name of any size!! Thus you haveto allocate memory (using malloc()) to read the inpu