C語言結(jié)構(gòu)體鏈表和指針實(shí)現(xiàn)學(xué)生管理系統(tǒng)
本文實(shí)例為大家分享了C語言結(jié)構(gòu)體鏈表和指針實(shí)現(xiàn)學(xué)生管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
一、需求分析
通過使用“學(xué)生管理系統(tǒng)”,可以更加有效地對(duì)學(xué)生實(shí)現(xiàn)管理,完成對(duì)學(xué)生基本信息以及成績信息的文件保存,具有信息的增加,刪除、查詢以及修改等功能,能提供簡(jiǎn)單的數(shù)據(jù)統(tǒng)計(jì)、分析信息。
二、整體設(shè)計(jì)
學(xué)生管理系統(tǒng) 主要由兩大功能模塊組成,分別是是“學(xué)生檔案管理”和“學(xué)生成績管理“兩個(gè)子系統(tǒng)。整體模塊架構(gòu)如下:
三、詳細(xì)設(shè)計(jì)
學(xué)生檔案管理子系統(tǒng)
- 用戶選擇
進(jìn)入“學(xué)生檔案管理”子系統(tǒng),顯示該子系統(tǒng)菜單,用戶分別可選擇:錄入數(shù)據(jù)、查詢數(shù)據(jù)、修改數(shù)據(jù)、刪除數(shù)據(jù)、增加數(shù)據(jù)、統(tǒng)計(jì)分析、退出系統(tǒng)等功能。
- 錄入數(shù)據(jù)
主要實(shí)現(xiàn)函數(shù)為 readin_record( ) ,能引導(dǎo)用戶輸入學(xué)生人數(shù),依次錄入每個(gè)學(xué)生的學(xué)號(hào)、姓名、性別、出生日期、班級(jí)、生源地(具體到省、自治區(qū)和直轄市)等信息。采用結(jié)構(gòu)體Stu_record數(shù)據(jù)類型保存學(xué)生檔案信息。結(jié)構(gòu)體中含有學(xué)號(hào)、姓名、性別、出生日期、班級(jí)、生源地(具體到省、自治區(qū)和直轄市)共六項(xiàng)信息。
數(shù)據(jù)存儲(chǔ)由鏈表實(shí)現(xiàn),讀入數(shù)據(jù)完成后,按學(xué)號(hào)排序輸出,并將其保存在磁盤文件Tdata_new.txt中。
- 查詢數(shù)據(jù)
采用函數(shù)menu3_inquire_record ()。設(shè)置查詢菜單,分為按學(xué)號(hào)查詢id_inquiry_record()、按姓名查詢name_inquiry_record()、按班級(jí)查詢clas_inquiry_record()、按生源地查詢syd_inquiry_record()、多條件組合查詢(班級(jí)與生源地組合查詢)clasSyd_inquiry_record()、全部顯示search()、退出查詢等功能。
- 修改數(shù)據(jù)
采用函數(shù)modify_record()。用戶輸入修改學(xué)生的學(xué)號(hào),系統(tǒng)顯示該生信息。用switch case語句設(shè)置修改選項(xiàng),選擇修改學(xué)號(hào)、姓名、性別、出生日期、班級(jí)、生源地、修改全部、保存并退出修改等。在磁盤文件Tdata_new.txt中修改相應(yīng)信息。
- 刪除數(shù)據(jù)
采用函數(shù)delete_record()。用戶輸入刪除學(xué)生的學(xué)號(hào),刪除前系統(tǒng)提示用戶再次確認(rèn)是否刪除。注意需要在學(xué)生成績管理系統(tǒng)同步刪除該生信息。
- 增加數(shù)據(jù)
采用函數(shù)add_record()。引導(dǎo)用戶輸入增加學(xué)生的學(xué)號(hào)、姓名、性別、出生日期、班級(jí)、生源地信息,更新磁盤文件。
- 統(tǒng)計(jì)分析
采用函數(shù)statistics_record()。顯示各生源地的人數(shù)以及所占百分比。
學(xué)生成績管理子系統(tǒng)
- 用戶選擇
進(jìn)入“學(xué)生成績管理”子系統(tǒng),顯示該子系統(tǒng)菜單,用戶分別可選擇:錄入數(shù)據(jù)、查詢數(shù)據(jù)、修改數(shù)據(jù)、刪除數(shù)據(jù)、增加數(shù)據(jù)、統(tǒng)計(jì)分析、退出系統(tǒng)等功能。
- 錄入數(shù)據(jù)
主要實(shí)現(xiàn)函數(shù)為 readin_score ( ) ,能引導(dǎo)用戶輸入學(xué)生人數(shù),依次錄入每個(gè)學(xué)生的學(xué)號(hào)、姓名、班級(jí)、課程成績等信息。采用結(jié)構(gòu)體Stu_score數(shù)據(jù)類型保存學(xué)生成績信息。結(jié)構(gòu)體中含有學(xué)號(hào)、姓名、班級(jí)、課程數(shù)據(jù),其中課程數(shù)據(jù)包括3門課程的成績以及平均成績。
讀入數(shù)據(jù)完成后,根據(jù)用戶輸入的3門課程成績自動(dòng)計(jì)算平均分avg, 將所有數(shù)據(jù)保存在磁盤文件Tscore_new.txt中。
- 查詢數(shù)據(jù)
采用函數(shù)inquiry_score()。設(shè)置查詢菜單,分為按學(xué)號(hào)查詢id_inquiry_score()、按姓名查詢name_inquiry_score()、按班級(jí)查詢clas_inquiry_score()、退出查詢等功能。
- 修改數(shù)據(jù)
采用函數(shù)modify_ score ()。用戶輸入修改學(xué)生的學(xué)號(hào),系統(tǒng)顯示該生信息。用switch case語句設(shè)置修改選項(xiàng),選擇修改學(xué)號(hào)、姓名、班級(jí)、課程1成績、課程2成績、課程3成績、保存并退出修改等。在磁盤文件Tscore_new.txt中修改相應(yīng)信息。
- 刪除數(shù)據(jù)
采用函數(shù)delete_ score ()。用戶輸入刪除學(xué)生的學(xué)號(hào),刪除前系統(tǒng)提示用戶再次確認(rèn)是否刪除。注意需要在學(xué)生檔案管理系統(tǒng)同步刪除該生信息。
- 增加數(shù)據(jù)
采用函數(shù)add_ score ()。引導(dǎo)用戶輸入增加學(xué)生的學(xué)號(hào)、姓名、班級(jí)、課程1成績、課程2成績和課程3成績。系統(tǒng)自動(dòng)計(jì)算平均分。更新磁盤文件。
- 統(tǒng)計(jì)分析
采用函數(shù)menu3_statistics_score ()。設(shè)置統(tǒng)計(jì)分析菜單,分為按學(xué)生分析和按課程分析。若用戶選擇按學(xué)生分析stu_statistics_score(),該函數(shù)統(tǒng)計(jì)輸出有不及格課程的學(xué)生的人數(shù)和其所占百分比。若用戶選擇按課程分析course_statistics_score(),該函數(shù)分析并輸出每門課程的最高分、最低分、平均分。
四、代碼實(shí)現(xiàn)
文件 main.c
#include<stdio.h> #include<string.h> #include <stdlib.h> #include<stdio.h> #include<malloc.h> #include"student.h" /*函數(shù)聲明*/ void menu1(); void menu2_record(); void menu2_score(); int main() { ? ? while(1) ?? ?{ ?? ??? ?int n; ?? ??? ?menu1(); ?? ??? ?printf("請(qǐng)輸入您的選擇:\n"); ?? ??? ?scanf("%d",&n); ?? ??? ?switch (n) ?? ??? ?{ ?? ??? ??? ?case 1: menu2_record() ;break; ?? ??? ??? ?case 2: menu2_score() ;break; ?? ??? ??? ?case 0: return 0; ?? ??? ??? ?default: printf("您的選擇錯(cuò)誤,請(qǐng)重新輸入。\n"); ?? ??? ?} ?? ??? ?system("pause"); ?? ??? ?system("cls"); ?? ?} ? ? return 0; }
文件 student.h
#include<stdio.h> #include<string.h> #include <stdlib.h> #include<stdio.h> #include<malloc.h> struct Date { ? ? int year; ? ? int month; ? ? int day; }; enum Depart {sdjinan,sdqingdao,sdyantai,sdweifang,sdheze,sddezhou,sdbinzhou,sdweihai}; struct Stu_record { ? ? int id; ? ? char name[20]; ? ? char sex[10]; ? ? struct Date birth; ? ? int clas; ? ? enum Depart syd; ? ? struct Stu_record *next; }; struct Stu_record *head = NULL; struct Stu_score { ? ? int id; ? ? char name[20]; ? ? int clas; ? ? double course1; ? ? double course2; ? ? double course3; ? ? double avg; ? ? struct Stu_score *next; }; /*函數(shù)聲明*/ struct Stu_record *readin_record(); void menu3_inquire_record(); void id_inquiry_record(struct Stu_record *head); void name_inquiry_record(struct Stu_record *head); void clas_inquiry_record(struct Stu_record *head); void syd_inquiry_record(struct Stu_record *head); void clasSyd_inquiry_record(struct Stu_record *head); void modify_record(struct Stu_record *head); struct Stu_record *delete_record(struct Stu_record *head); struct Stu_record *add_record(struct Stu_record *head); void statistics_record(struct Stu_record *head); struct Stu_score *readin_score(); void menu3_inquire_score(); void id_inquiry_score(struct Stu_score *head); void name_inquiry_score(struct Stu_score *head); void clas_inquiry_score(struct Stu_score *head); void modify_score(struct Stu_score *head) ; struct Stu_score *delete_score(struct Stu_score *head) ; struct Stu_score *add_score(struct Stu_score *head) ; void menu3_statistics_score(); void stu_statistics_score(struct Stu_score *head); void course_statistics_score(struct Stu_score *head); /********** 公共函數(shù) **********/ struct Stu_record *insert(struct Stu_record *head, struct Stu_record *stu) { ? ? struct Stu_record *p1, *p2; ? ? if (stu == NULL) ? ? { ? ? ? ? printf("請(qǐng)按照學(xué)號(hào)、姓名、性別、出生日期(如1999 9 9)、班級(jí)、生源地\n(0:山東濟(jì)南 1:山東青島 2:山東煙臺(tái) 3:山東濰坊 4:山東菏澤 5:山東德州 6:山東濱州 7:山東威海)順序輸入\n"); ? ? ? ? stu = (struct Stu_record *) malloc(sizeof(struct Stu_record)); ? ? ? ? while (!scanf("%d %s %s %d %d %d %d %d", &stu->id, stu->name, stu->sex, &stu->birth.year, &stu->birth.month,&stu->birth.day,&stu->clas, &stu->syd)) ? ? ? ? { ? ? ? ? ? ? printf("輸入信息有誤,請(qǐng)重新輸入\n"); ? ? ? ? ? ? fflush(stdin); ? ? ? ? } ? ? } ? ? if (head == NULL) ? ? { ? ? ? ? head = stu; ? ? ? ? head->next = NULL; ? ? } ? ? else ? ? { ? ? ? ? p1 = p2 = head; ? ? ? ? while (stu->id > p1->id && p1->next != NULL) ? ? ? ? { ? ? ? ? ? ? p2 = p1; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p2 == p1) ? ? ? ? { ? ? ? ? ? ? if (stu->id < p2->id) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? head = stu; ? ? ? ? ? ? ? ? stu->next = p2; ? ? ? ? ? ? } ? ? ? ? ? ? else ? ? ? ? ? ? { ? ? ? ? ? ? ? ? p2->next = stu; ? ? ? ? ? ? ? ? stu->next = NULL; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? if (stu->id < p1->id) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? p2->next = stu; ? ? ? ? ? ? ? ? stu->next = p1; ? ? ? ? ? ? } ? ? ? ? ? ? else ? ? ? ? ? ? { ? ? ? ? ? ? ? ? p1->next = stu; ? ? ? ? ? ? ? ? stu->next = NULL; ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? return(head); } struct Stu_score *sinsert(struct Stu_score *head, struct Stu_score *stu) { ? ? struct Stu_score *p1, *p2; ? ? if (stu == NULL) ? ? { ? ? ? ? printf("請(qǐng)按照學(xué)號(hào)、姓名、班級(jí)、課程1、課程2、課程3 順序輸入\n"); ? ? ? ? stu = (struct Stu_score *) malloc(sizeof(struct Stu_score)); ? ? ? ? while (!scanf("%d %s %d %lf %lf %lf", &stu->id, stu->name, &stu->clas, &stu->course1, &stu->course2,&stu->course3)) ? ? ? ? { ? ? ? ? ? ? printf("輸入信息有誤,請(qǐng)重新輸入\n"); ? ? ? ? ? ? fflush(stdin); ? ? ? ? } ? ? ? ? stu->avg=(stu->course1+stu->course2+stu->course3)/3.0; ? ? } ? ? if (head == NULL) ? ? { ? ? ? ? head = stu; ? ? ? ? head->next = NULL; ? ? } ? ? else ? ? { ? ? ? ? p1 = p2 = head; ? ? ? ? while (stu->id > p1->id && p1->next != NULL) ? ? ? ? { ? ? ? ? ? ? p2 = p1; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p2 == p1) ? ? ? ? { ? ? ? ? ? ? if (stu->id < p2->id) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? head = stu; ? ? ? ? ? ? ? ? stu->next = p2; ? ? ? ? ? ? } ? ? ? ? ? ? else ? ? ? ? ? ? { ? ? ? ? ? ? ? ? p2->next = stu; ? ? ? ? ? ? ? ? stu->next = NULL; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? if (stu->id < p1->id) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? p2->next = stu; ? ? ? ? ? ? ? ? stu->next = p1; ? ? ? ? ? ? } ? ? ? ? ? ? else ? ? ? ? ? ? { ? ? ? ? ? ? ? ? p1->next = stu; ? ? ? ? ? ? ? ? stu->next = NULL; ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? return(head); } void search(struct Stu_record *head) { ? ? struct Stu_record *p1; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? printf(" ?學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? printf("———————————————————————————\n"); ? ? while (p1 != NULL) ? ? { ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? p1 = p1->next; ? ? } ? ? printf("\n"); } void ssearch(struct Stu_score *head) { ? ? struct Stu_score *p1; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? printf(" ?學(xué)號(hào) ? 姓名 ? 班級(jí) ? ?課程1 ? ? 課程2 ? ?課程3 ? ?平均分 ?\n"); ? ? printf("—————————————————————————————————\n"); ? ? while (p1 != NULL) ? ? { ? ? ? ? printf("%-7d %-7s %-7d %-5.2lf ? ?%-5.2lf ? ?%-5.2lf ? %-5.2lf\n", p1->id, p1->name, p1->clas, p1->course1, p1->course2, p1->course3, p1->avg); ? ? ? ? p1 = p1->next; ? ? } ? ? printf("\n"); } /*** 一堆menu函數(shù)的定義 ***/ void menu1() { ? ? printf(" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \n"); ? ? printf(" ? ? ? ? ? ? ? 歡迎進(jìn)入學(xué)生管理系統(tǒng) ? ? ? ? ? ? ? ? ? ?\n"); ? ? printf("-------------------------------------------------------\n"); ? ? printf(" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \n"); ? ? printf("*************StudentInformationManagement**************\n"); ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? printf("*\t\t1.進(jìn)入學(xué)生檔案管理子系統(tǒng) ? ? ? ? ? ? ?*\n"); ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? printf("*\t\t2.進(jìn)入學(xué)生成績管理子系統(tǒng) ? ? ? ? ? ? ?*\n"); ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? printf("*\t\t0.退出系統(tǒng) ? ? ? ? ? ? ? ? ? ? ? ? ? ?*\n"); ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? printf("*******************************************************\n\n"); } void menu2_record() { ? ? while(1) ? ? { ? ? ? ? int n; ? ? ? ? printf("********學(xué)生檔案管理*********\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*\t1.錄入數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t2.查詢數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t3.修改數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t4.刪除數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t5.增加數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t6.統(tǒng)計(jì)分析 ? ? ? ? ?*\n"); ? ? ? ? printf("*\t0.退出系統(tǒng) ? ? ? ? ?*\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*****************************\n\n"); ? ? ? ? printf("請(qǐng)輸入您的選擇:\n"); ? ? ? ? scanf("%d",&n); ? ? ? ? switch (n) ? ? ? ? { ? ? ? ? case 1: ? ? ? ? ? ? readin_record() ; ? ? ? ? ? ? break; ? ? ? ? case 2: ? ? ? ? ? ? menu3_inquire_record() ; ? ? ? ? ? ? break; ? ? ? ? case 3: ? ? ? ? ? ? modify_record(head) ; ? ? ? ? ? ? break; ? ? ? ? case 4: ? ? ? ? ? ? delete_record(head) ; ? ? ? ? ? ? break; ? ? ? ? case 5: ? ? ? ? ? ? head=add_record(head); ? ? ? ? ? ? search(head); ? ? ? ? ? ? break; ? ? ? ? case 6: ? ? ? ? ? ? statistics_record(head) ; ? ? ? ? ? ? break; ? ? ? ? case 0: ? ? ? ? ? ? return; ? ? ? ? default: ? ? ? ? ? ? printf("您的選擇錯(cuò)誤,請(qǐng)重新輸入。\n"); ? ? ? ? } ? ? ? ? system("pause"); ? ? ? ? system("cls"); ? ? } } void menu2_score() { ? ? while(1) ? ? { ? ? ? ? int n; ? ? ? ? printf("********學(xué)生成績管理*********\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*\t1.錄入數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t2.查詢數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t3.修改數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t4.刪除數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t5.增加數(shù)據(jù) ? ? ? ? ?*\n"); ? ? ? ? printf("*\t6.統(tǒng)計(jì)分析 ? ? ? ? ?*\n"); ? ? ? ? printf("*\t0.退出系統(tǒng) ? ? ? ? ?*\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*****************************\n\n"); ? ? ? ? printf("請(qǐng)輸入您的選擇:\n"); ? ? ? ? scanf("%d",&n); ? ? ? ? switch (n) ? ? ? ? { ? ? ? ? case 1: ? ? ? ? ? ? readin_score() ; ? ? ? ? ? ? break; ? ? ? ? case 2: ? ? ? ? ? ? menu3_inquire_score(); ? ? ? ? ? ? break; ? ? ? ? case 3: ? ? ? ? ? ? modify_score(head); ? ? ? ? ? ? break; ? ? ? ? case 4: ? ? ? ? ? ? delete_score(head); ? ? ? ? ? ? break; ? ? ? ? case 5: ? ? ? ? ? ? head=add_score(head); ? ? ? ? ? ? ssearch(head); ? ? ? ? ? ? break; ? ? ? ? case 6: ? ? ? ? ? ? menu3_statistics_score() ; ? ? ? ? ? ? break; ? ? ? ? case 0: ? ? ? ? ? ? return; ? ? ? ? default: ? ? ? ? ? ? printf("您的選擇錯(cuò)誤,請(qǐng)重新輸入。\n"); ? ? ? ? } ? ? ? ? system("pause"); ? ? ? ? system("cls"); ? ? } } void menu3_inquire_record() { ? ? while(1) ? ? { ? ? ? ? int n; ? ? ? ? printf("************查詢菜單*************\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*\t1.按學(xué)號(hào)查詢 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t2.按姓名查詢 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t3.按班級(jí)查詢 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t4.按生源地查詢 ? ? ? ? ?*\n"); ? ? ? ? printf("*\t5.多條件組合查詢 ? ? ? ?*\n"); ? ? ? ? printf("*\t6.全部顯示 ? ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t0.退出查詢 ? ? ? ? ? ? ?*\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*********************************\n\n"); ? ? ? ? printf("請(qǐng)輸入您的選擇:\n"); ? ? ? ? scanf("%d",&n); ? ? ? ? switch (n) ? ? ? ? { ? ? ? ? case 1: ? ? ? ? ? ? id_inquiry_record(head); ? ? ? ? ? ? break; ? ? ? ? case 2: ? ? ? ? ? ? name_inquiry_record(head) ; ? ? ? ? ? ? break; ? ? ? ? case 3: ? ? ? ? ? ? clas_inquiry_record(head) ; ? ? ? ? ? ? break; ? ? ? ? case 4: ? ? ? ? ? ? syd_inquiry_record(head) ; ? ? ? ? ? ? break; ? ? ? ? case 5: ? ? ? ? ? ? clasSyd_inquiry_record(head) ; ? ? ? ? ? ? break; ? ? ? ? case 6: ? ? ? ? ? ? search(head); ? ? ? ? ? ? break; ? ? ? ? case 0: ? ? ? ? ? ? return; ? ? ? ? default: ? ? ? ? ? ? printf("您的選擇錯(cuò)誤,請(qǐng)重新輸入。\n"); ? ? ? ? } ? ? ? ? system("pause"); ? ? ? ? system("cls"); ? ? } } void menu3_inquire_score() { ? ? while(1) ? ? { ? ? ? ? int n; ? ? ? ? printf("************查詢菜單*************\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*\t1.按學(xué)號(hào)查詢 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t2.按姓名查詢 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t3.按班級(jí)查詢 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t4.全部顯示 ? ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t0.退出查詢 ? ? ? ? ? ? ?*\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*********************************\n\n"); ? ? ? ? printf("請(qǐng)輸入您的選擇:\n"); ? ? ? ? scanf("%d",&n); ? ? ? ? switch (n) ? ? ? ? { ? ? ? ? case 1: ? ? ? ? ? ? id_inquiry_score(head); ? ? ? ? ? ? break; ? ? ? ? case 2: ? ? ? ? ? ? name_inquiry_score(head) ; ? ? ? ? ? ? break; ? ? ? ? case 3: ? ? ? ? ? ? clas_inquiry_score(head) ; ? ? ? ? ? ? break; ? ? ? ? case 4: ? ? ? ? ? ? ssearch(head); ? ? ? ? ? ? break; ? ? ? ? case 0: ? ? ? ? ? ? return; ? ? ? ? default: ? ? ? ? ? ? printf("您的選擇錯(cuò)誤,請(qǐng)重新輸入。\n"); ? ? ? ? } ? ? ? ? system("pause"); ? ? ? ? system("cls"); ? ? } } void menu3_statistics_score() { ? ? ?while(1) ? ? { ? ? ? ? int n; ? ? ? ? printf("************統(tǒng)計(jì)分析*************\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*\t1.按學(xué)生分析 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t2.按課程分析 ? ? ? ? ? ?*\n"); ? ? ? ? printf("*\t0.退出統(tǒng)計(jì)分析 ? ? ? ? ?*\n"); ? ? ? ? printf("* ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *\n"); ? ? ? ? printf("*********************************\n\n"); ? ? ? ? printf("請(qǐng)輸入您的選擇:\n"); ? ? ? ? scanf("%d",&n); ? ? ? ? switch (n) ? ? ? ? { ? ? ? ? case 1: ? ? ? ? ? ? stu_statistics_score(head); ? ? ? ? ? ? break; ? ? ? ? case 2: ? ? ? ? ? ? course_statistics_score(head) ; ? ? ? ? ? ? break; ? ? ? ? case 0: ? ? ? ? ? ? return; ? ? ? ? default: ? ? ? ? ? ? printf("您的選擇錯(cuò)誤,請(qǐng)重新輸入。\n"); ? ? ? ? } ? ? ? ? system("pause"); ? ? ? ? system("cls"); ? ? } } /****** record中函數(shù) ******/ struct Stu_record *readin_record() { ? ? struct Stu_record *p2,*p1; ? ? int n,i; ? ? head=NULL; ? ? FILE *w; ? ? if ((w = fopen("C:\\Desktop\\Tdata_new.txt", "wb+")) == NULL) ? ? { ? ? ? ? printf("cannot open file\n"); ? ? ? ? exit(1); ? ? } ? ? printf("請(qǐng)輸入學(xué)生人數(shù): \n"); ? ? scanf("%d",&n); ? ? head=p2=p1=(struct Stu_record *) malloc(sizeof(struct Stu_record));?? ??? ??? ??? ??? ??? ??? ??? ?//開辟內(nèi)存,用于生成鏈表 ? ? printf("學(xué)生個(gè)數(shù)為:%d個(gè),請(qǐng)按照以下順序輸入\n", n);?? ??? ??? ??? ??? ??? ??? ?//對(duì)學(xué)生總數(shù)的提示,并且提示每個(gè)學(xué)生信息的輸入順序 ? ? printf("學(xué)號(hào)、姓名、性別、出生日期(如1999 9 9)、班級(jí)、生源地\n(0:山東濟(jì)南 1:山東青島 2:山東煙臺(tái) 3:山東濰坊 4:山東菏澤 5:山東德州 6:山東濱州 7:山東威海)\n");?? ?//每個(gè)學(xué)生信息的輸入順序 ? ? for (i = 0; i < n; i++) ? ? { ? ? ? ? while (!scanf("%d %s %s %d %d %d %d %d", &p2->id, p2->name, p2->sex, &p2->birth.year, &p2->birth.month,&p2->birth.day,&p2->clas, &p2->syd)) ? ? ? ? { ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入該學(xué)生信息\n ? "); ? ? ? ? ? ? fflush(stdin); ? ? ? ? } ? ? ? ? if (n == 1) ? ? ? ? { ? ? ? ? ? ? p2->next = NULL; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? head = insert(head, p2); ? ? ? ? ? ? p2 = (struct Student *) malloc(sizeof(struct Stu_record)); ? ? ? ? } ? ? } ? ? p1=head; ? ? while(p1!=NULL) ? ? { ? ? ? ? fprintf(w,"%d %s %s %d %d %d %d %d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month,p1->birth.day,p1->clas, p1->syd); ? ? ? ? p1= p1->next; ? ? } ? ? fclose(w); ? ? printf("成功錄入%d名學(xué)生信息,學(xué)生信息已經(jīng)按學(xué)號(hào)從小到大排列,信息如下: \n\n",n); ? ? search(head); ? ? return head; } void id_inquiry_record(struct Stu_record *head) { ? ? int cho, t = 1; ? ? int num; ? ? struct Stu_record *p1; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if ( t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (p1->id != num) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->id == num) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? ? ? ? ? printf("———————————————————————————\n"); ? ? ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void name_inquiry_record(struct Stu_record *head) { ? ? int cho, t = 1; ? ? char qname[20]; ? ? struct Stu_record *p1; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if ( t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生姓名: "); ? ? ? ? ? ? while (!scanf("%s", qname)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (strcmp(p1->name,qname)!=0) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (strcmp(p1->name,qname)==0) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? ? ? ? ? printf("———————————————————————————\n"); ? ? ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void clas_inquiry_record(struct Stu_record *head) { ? ? int cho, t = 1; ? ? struct Stu_record *p1; ? ? int qclas; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生班級(jí): "); ? ? ? ? ? ? while (!scanf("%d", &qclas)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (p1->clas != qclas) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->clas == qclas) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? ? ? ? ? printf("———————————————————————————\n"); ? ? ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void syd_inquiry_record(struct Stu_record *head) { ? ? int cho,t = 1; ? ? struct Stu_record *p1; ? ? int qsyd; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if ( t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生生源地: "); ? ? ? ? ? ? printf("(0:山東濟(jì)南 1:山東青島 2:山東煙臺(tái) 3:山東濰坊 4:山東菏澤 5:山東德州 6:山東濱州 7:山東威海)\n"); ? ? ? ? ? ? while (!scanf("%d", &qsyd)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (p1->syd != qsyd) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->syd == qsyd) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? ? ? ? ? printf("———————————————————————————\n"); ? ? ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void clasSyd_inquiry_record(struct Stu_record *head) { ? ? int cho, t = 1; ? ? struct Stu_record *p1; ? ? int qsyd,qclas; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if ( t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生生源地: "); ? ? ? ? ? ? while (!scanf("%d", &qsyd)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生班級(jí): "); ? ? ? ? ? ? while (!scanf("%d", &qclas)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (p1->syd != qsyd||p1->clas != qclas) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->syd == qsyd&&p1->clas == qclas) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? ? ? ? ? printf("———————————————————————————\n"); ? ? ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void modify_record(struct Stu_record *head) { ? ? struct Stu_record *p1, *p2; ? ? int num,cho,k=1,l=0; ? ? FILE *w; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束修改\n ? "); ? ? ? ? system("pause"); ? ? ? ? return; ? ? } ? ? printf("請(qǐng)輸入需要修改的學(xué)生學(xué)號(hào): "); ? ? while (!scanf("%d",&num)) ? ? { ? ? ? ? printf("輸入學(xué)號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? fflush(stdin); ? ? } ? ? do ? ? { ? ? ? ? p2 = p1 = head; ? ? ? ? while (p1->id != num) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p2 = p1; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->id == num) ? ? ? ? { ? ? ? ? ? ? printf("已找到該學(xué)生,該學(xué)生的信息為: \n"); ? ? ? ? ? ? printf("生源地(0:山東濟(jì)南 1:山東青島 2:山東煙臺(tái) 3:山東濰坊 4:山東菏澤 5:山東德州 6:山東濱州 7:山東威海)\n"); ? ? ? ? ? ? printf("學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? ? ? ? ? printf("———————————————————————————\n"); ? ? ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? ? ? l = 0; ? ? ? ? ? ? do ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (l == 0) ? ? ? ? ? ? ? ? ? ? printf("\n選擇修改的內(nèi)容\n"); ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? ? ? printf("序號(hào)輸入錯(cuò)誤,請(qǐng)重新選擇\n"); ? ? ? ? ? ? ? ? l = 1; ? ? ? ? ? ? ? ? printf(" ? 1.學(xué)號(hào)\n"); ? ? ? ? ? ? ? ? printf(" ? 2.姓名\n"); ? ? ? ? ? ? ? ? printf(" ? 3.性別\n"); ? ? ? ? ? ? ? ? printf(" ? 4.出生日期\n"); ? ? ? ? ? ? ? ? printf(" ? 5.班級(jí)\n"); ? ? ? ? ? ? ? ? printf(" ? 6.生源地\n"); ? ? ? ? ? ? ? ? printf(" ? 7.全部\n"); ? ? ? ? ? ? ? ? printf("請(qǐng)選擇序號(hào): "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? while (cho > 7 || cho < 1); ? ? ? ? ? ? switch (cho) ? ? ? ? ? ? { ? ? ? ? ? ? case 1: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的學(xué)號(hào)信息: "); ? ? ? ? ? ? ? ? while (!scanf("%d", &p1->id)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 2: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的姓名信息: "); ? ? ? ? ? ? ? ? while (!scanf("%s", p1->name)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 3: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的性別信息: "); ? ? ? ? ? ? ? ? while (!scanf("%s", p1->sex)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 4: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的出生年月信息(如輸入1999 9 9): "); ? ? ? ? ? ? ? ? while (!scanf("%d %d %d", &p1->birth.year,&p1->birth.month,&p1->birth.day)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 5: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的班級(jí)信息: "); ? ? ? ? ? ? ? ? while (!scanf("%d",&p1->clas)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 6: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的生源地信息: "); ? ? ? ? ? ? ? ? printf("生源地(0:山東濟(jì)南 1:山東青島 2:山東煙臺(tái) 3:山東濰坊 4:山東菏澤 5:山東德州 6:山東濱州 7:山東威海)\n"); ? ? ? ? ? ? ? ? while (!scanf("%d",&p1->syd)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 7: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生全部要改正的信息: "); ? ? ? ? ? ? ? ? while (!scanf("%d %s %s %d %d %d %d %d",&p1->id, p1->name, p1->sex, &p1->birth.year, &p1->birth.month, &p1->birth.day, &p1->clas, &p1->syd)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? if (cho == 1 || cho == 7) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (p1 == head) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? head = head->next; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else if (p1->next == NULL) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? p2->next = NULL; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? p2->next = p1->next; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? head = insert(head,p1); ? ? ? ? ? ? } ? ? ? ? ? ? printf("修改成功,該學(xué)生改正后的信息為: \n"); ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? ?性別 ? ?出生日期 ? ? ? 班級(jí) ? ?生源地 ?\n"); ? ? ? ? ? ? printf("———————————————————————————\n"); ? ? ? ? ? ? printf("%-7d ?%-4s ?%-6s ?%-4d年%-2d月%-2d日 ? %-6d ?%-6d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month, p1->birth.day, p1->clas, p1->syd); ? ? ? ? ? ? printf(" ? 1.繼續(xù)修改其他學(xué)生信息\n"); ? ? ? ? ? ? printf(" ? 2.退出修改\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d",&k)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? if (k == 1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入需要修改的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入修改信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? else if (k != 2) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入\n"); ? ? ? ? ? ? } ? ? ? ? ? ? if ((w = fopen("C:\\Desktop\\Tdata_new.txt", "wb+")) == NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("cannot open file\n"); ? ? ? ? ? ? ? ? exit(1); ? ? ? ? ? ? } ? ? ? ? ? ? p1=head; ? ? ? ? ? ? while(p1!=NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? fprintf(w,"%d %s %s %d %d %d %d %d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month,p1->birth.day,p1->clas, p1->syd); ? ? ? ? ? ? ? ? p1= p1->next; ? ? ? ? ? ? } ? ? ? ? ? ? fclose(w); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? k = 1; ? ? ? ? ? ? printf("找不到該學(xué)生信息,請(qǐng)重新輸入需要修改的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入修改信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(k == 1); ? ? printf(" ? "); ? ? system("pause"); } struct Stu_record *delete_record(struct Stu_record *head) { ? ? int num,k; ? ? FILE *w; ? ? struct Stu_record *p1,*p2; ? ? if(head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束刪除\n"); ? ? ? ? return(head); ? ? } ? ? printf("請(qǐng)輸入要?jiǎng)h除的學(xué)生學(xué)號(hào): "); ? ? while (!scanf("%d", &num)) ? ? { ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入學(xué)生學(xué)號(hào): "); ? ? ? ? fflush(stdin); ? ? } ? ? do ? ? { ? ? ? ? p1 = p2 = head; ? ? ? ? while (num != p1->id && p1->next != NULL) ? ? ? ? { ? ? ? ? ? ? p2 = p1; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (num == p1->id) ? ? ? ? { ? ? ? ? ? ? if (num == p1->id) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (p1->next == NULL && p1 == head) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? ? ? head = NULL; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else if (p1->next == NULL)//如果刪除完表空了 把表刪除 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? ? ? p2->next = NULL; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else if (head == p1) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? head = p1->next; ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? p2->next = p1->next; ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? printf("成功刪除學(xué)生信息\n"); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該同學(xué)信息\n"); ? ? ? ? ? ? fflush(stdin); ? ? ? ? } ? ? ? ? if (head == NULL) ? ? ? ? { ? ? ? ? ? ? printf("沒有學(xué)生信息,結(jié)束刪除\n"); ? ? ? ? ? ? return(head); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf(" ? 1.繼續(xù)刪除學(xué)生信息\n"); ? ? ? ? ? ? printf(" ? 2.結(jié)束刪除\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d",&k)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入選擇的序號(hào): "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? if (k == 1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入要?jiǎng)h除的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? else if (k != 2) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? k = 1; ? ? ? ? ? ? } ? ? ? ? ? ? if ((w = fopen("C:\\Desktop\\Tdata_new.txt", "wb+")) == NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("cannot open file\n"); ? ? ? ? ? ? ? ? exit(1); ? ? ? ? ? ? } ? ? ? ? ? ? p1=head; ? ? ? ? ? ? while(p1!=NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? fprintf(w,"%d %s %s %d %d %d %d %d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month,p1->birth.day,p1->clas, p1->syd); ? ? ? ? ? ? ? ? p1= p1->next; ? ? ? ? ? ? } ? ? ? ? ? ? fclose(w); ? ? ? ? } ? ? } ? ? while (k == 1); ? ? return(head); } struct Stu_record *add_record(struct Stu_record *head) { ? ? FILE *w; ? ? int i,num; ? ? struct Stu_record *p1; ? ? head = insert(head, NULL); ? ? printf(" ? 成功插入學(xué)生信息\n ? "); ? ? if ((w = fopen("C:\\Desktop\\Tdata_new.txt", "wb+")) == NULL) ? ? { ? ? ? ? printf("cannot open file\n"); ? ? ? ? exit(1); ? ? } ? ? p1=head; ? ? while(p1!=NULL) ? ? { ? ? ? ? fprintf(w,"%d %s %s %d %d %d %d %d\n", p1->id, p1->name, p1->sex, p1->birth.year, p1->birth.month,p1->birth.day,p1->clas, p1->syd); ? ? ? ? p1= p1->next; ? ? } ? ? fclose(w); ? ? return head; } void statistics_record(struct Stu_record *head) { ? ? double cnt[8]; ? ? int i; ? ? double sum=0; ? ? struct Stu_record *p1; ? ? p1 = head; ? ? memset(cnt,0,sizeof(cnt)); ? ? printf("統(tǒng)計(jì)各生源地人數(shù)及所占百分比:\n"); ? ? while (1) ? ? { ? ? ? ? sum++; ? ? ? ? for(i=0;i<8;i++) ? ? ? ? { ? ? ? ? ? ? if(p1->syd==i) cnt[i]++; ? ? ? ? } ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? break; ? ? ? ? p1 = p1->next; ? ? } ? ? printf("全體學(xué)生人數(shù):%.0lf人\n\n",sum); ? ? printf("山東濟(jì)南:%.0lf人 %5.2lf%%\n",cnt[0],(cnt[0]/sum)*100); ? ? printf("山東青島:%.0lf人 %5.2lf%%\n",cnt[1],(cnt[1]/sum)*100); ? ? printf("山東煙臺(tái):%.0lf人 %5.2lf%%\n",cnt[2],(cnt[2]/sum)*100); ? ? printf("山東濰坊:%.0lf人 %5.2lf%%\n",cnt[3],(cnt[3]/sum)*100); ? ? printf("山東菏澤:%.0lf人 %5.2lf%%\n",cnt[4],(cnt[4]/sum)*100); ? ? printf("山東德州:%.0lf人 %5.2lf%%\n",cnt[5],(cnt[5]/sum)*100); ? ? printf("山東濱州:%.0lf人 %5.2lf%%\n",cnt[6],(cnt[6]/sum)*100); ? ? printf("山東威海:%.0lf人 %5.2lf%%\n\n",cnt[7],(cnt[7]/sum)*100); } /*** score中的函數(shù) ***/ struct Stu_score *readin_score() { ? ? struct Stu_score *p2,*p1; ? ? int n,i; ? ? head=NULL; ? ? FILE *w; ? ? if ((w = fopen("C:\\Desktop\\Tscore_new.txt", "wb+")) == NULL) ? ? { ? ? ? ? printf("cannot open file\n"); ? ? ? ? exit(1); ? ? } ? ? printf("請(qǐng)輸入學(xué)生人數(shù): \n"); ? ? scanf("%d",&n); ? ? head=p2=p1=(struct Stu_score *) malloc(sizeof(struct Stu_score));?? ??? ??? ??? ??? ??? ??? ??? ?//開辟內(nèi)存,用于生成鏈表 ? ? printf("學(xué)生個(gè)數(shù)為:%d個(gè),請(qǐng)按照以下順序輸入\n", n);?? ??? ??? ??? ??? ??? ??? ?//對(duì)學(xué)生總數(shù)的提示,并且提示每個(gè)學(xué)生信息的輸入順序 ? ? printf("學(xué)號(hào)、姓名、班級(jí)、課程1、課程2、課程3\n");?? ?//每個(gè)學(xué)生信息的輸入順序 ? ? for (i = 0; i < n; i++) ? ? { ? ? ? ? while (!scanf("%d %s %d %lf %lf %lf", &p2->id, p2->name, &p2->clas, &p2->course1, &p2->course2,&p2->course3)) ? ? ? ? { ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入該學(xué)生信息\n ? "); ? ? ? ? ? ? fflush(stdin); ? ? ? ? } ? ? ? ? p2->avg = (p2->course1+p2->course2+p2->course3)/3.0; ? ? ? ? if (n == 1) ? ? ? ? { ? ? ? ? ? ? p2->next = NULL; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? head = sinsert(head, p2); ? ? ? ? ? ? p2 = (struct Stu_score *) malloc(sizeof(struct Stu_score)); ? ? ? ? } ? ? } ? ? p1=head; ? ? while(p1!=NULL) ? ? { ? ? ? ? fprintf(w,"%d %s %d %lf %lf %lf\n",p2->id, p2->name, p2->clas, p2->course1, p2->course2,p2->course3,p2->avg); ? ? ? ? p1= p1->next; ? ? } ? ? fclose(w); ? ? printf("成功錄入%d名學(xué)生成績信息,學(xué)生成績信息已經(jīng)按學(xué)號(hào)從小到大排列,信息如下: \n\n",n); ? ? ssearch(head); ? ? return head; } void id_inquiry_score(struct Stu_score *head) { ? ? int cho, t = 1; ? ? int num; ? ? struct Stu_score *p1; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if ( t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (p1->id != num) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->id == num) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? 班級(jí) ? ?課程1 ? ? 課程2 ? ?課程3 ? ?平均分 ?\n"); ? ? ? ? ? ? printf("—————————————————————————————————\n"); ? ? ? ? ? ? printf("%-7d %-7s %-7d %-5.2lf ? ?%-5.2lf ? ?%-5.2lf ? %-5.2lf\n", p1->id, p1->name, p1->clas, p1->course1, p1->course2, p1->course3, p1->avg); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void name_inquiry_score(struct Stu_score *head) { ? ? int cho, t = 1; ? ? char qname[20]; ? ? struct Stu_score *p1; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if ( t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生姓名: "); ? ? ? ? ? ? while (!scanf("%s",qname)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (strcmp(p1->name,qname)!=0) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (strcmp(p1->name,qname)==0) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? 班級(jí) ? ?課程1 ? ? 課程2 ? ?課程3 ? ?平均分 ?\n"); ? ? ? ? ? ? printf("—————————————————————————————————\n"); ? ? ? ? ? ? printf("%-7d %-7s %-7d %-5.2lf ? ?%-5.2lf ? ?%-5.2lf ? %-5.2lf\n", p1->id, p1->name, p1->clas, p1->course1, p1->course2, p1->course3, p1->avg); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void clas_inquiry_score(struct Stu_score *head) { ? ? int cho, t = 1; ? ? int qclas; ? ? struct Stu_score *p1; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束查詢\n"); ? ? ? ? return; ? ? } ? ? p1 = head; ? ? do ? ? { ? ? ? ? p1 = head; ? ? ? ? if ( t == 1) ? ? ? ? { ? ? ? ? ? ? printf("請(qǐng)輸入需要查詢的學(xué)生班級(jí): "); ? ? ? ? ? ? while (!scanf("%d", &qclas)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? t = 1; ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? cho = 2; ? ? ? ? } ? ? ? ? while (p1->clas != qclas) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->clas == qclas) ? ? ? ? { ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? 班級(jí) ? ?課程1 ? ? 課程2 ? ?課程3 ? ?平均分 ?\n"); ? ? ? ? ? ? printf("—————————————————————————————————\n"); ? ? ? ? ? ? printf("%-7d %-7s %-7d %-5.2lf ? ?%-5.2lf ? ?%-5.2lf ? %-5.2lf\n", p1->id, p1->name, p1->clas, p1->course1, p1->course2, p1->course3, p1->avg); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該學(xué)生\n"); ? ? ? ? } ? ? ? ? if (t == 1) ? ? ? ? { ? ? ? ? ? ? printf("1.繼續(xù)查詢\n"); ? ? ? ? ? ? printf("2.結(jié)束查詢\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(cho==1); } void modify_score(struct Stu_score *head) { ? ? struct Stu_score *p1, *p2; ? ? int num,cho,k=1,l=0; ? ? FILE *w; ? ? if (head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生成績信息,結(jié)束修改\n "); ? ? ? ? system("pause"); ? ? ? ? return; ? ? } ? ? printf("請(qǐng)輸入需要修改的學(xué)生學(xué)號(hào): "); ? ? while (!scanf("%d",&num)) ? ? { ? ? ? ? printf("輸入學(xué)號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? fflush(stdin); ? ? } ? ? do ? ? { ? ? ? ? p2 = p1 = head; ? ? ? ? while (p1->id != num) ? ? ? ? { ? ? ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? p2 = p1; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (p1->id == num) ? ? ? ? { ? ? ? ? ? ? printf("已找到該學(xué)生,該學(xué)生的信息為: \n"); ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? 班級(jí) ? ?課程1 ? ? 課程2 ? ?課程3 ? ?平均分 ?\n"); ? ? ? ? ? ? printf("—————————————————————————————————\n"); ? ? ? ? ? ? printf("%-7d %-7s %-7d %-5.2lf ? ?%-5.2lf ? ?%-5.2lf ? %-5.2lf\n", p1->id, p1->name, p1->clas, p1->course1, p1->course2, p1->course3, p1->avg); ? ? ? ? ? ? l = 0; ? ? ? ? ? ? do ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (l == 0) ? ? ? ? ? ? ? ? ? ? printf("\n選擇修改的內(nèi)容\n"); ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? ? ? printf("序號(hào)輸入錯(cuò)誤,請(qǐng)重新選擇\n"); ? ? ? ? ? ? ? ? l = 1; ? ? ? ? ? ? ? ? printf(" ? 1.學(xué)號(hào)\n"); ? ? ? ? ? ? ? ? printf(" ? 2.姓名\n"); ? ? ? ? ? ? ? ? printf(" ? 3.班級(jí)\n"); ? ? ? ? ? ? ? ? printf(" ? 4.課程1成績\n"); ? ? ? ? ? ? ? ? printf(" ? 5.課程2成績\n"); ? ? ? ? ? ? ? ? printf(" ? 6.課程3成績\n"); ? ? ? ? ? ? ? ? printf(" ? 7.全部\n"); ? ? ? ? ? ? ? ? printf("請(qǐng)選擇序號(hào): "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? while (!scanf("%d", &cho)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? while (cho > 7 || cho < 1); ? ? ? ? ? ? switch (cho) ? ? ? ? ? ? { ? ? ? ? ? ? case 1: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的學(xué)號(hào)信息: "); ? ? ? ? ? ? ? ? while (!scanf("%d", &p1->id)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 2: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的姓名信息: "); ? ? ? ? ? ? ? ? while (!scanf("%s", p1->name)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 3: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的班級(jí)信息: "); ? ? ? ? ? ? ? ? while (!scanf("%d", &p1->clas)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 4: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的課程1成績信息: "); ? ? ? ? ? ? ? ? while (!scanf("%lf", &p1->course1)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? p1->avg=(p1->course1+p1->course2+p1->course3)/3.0; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 5: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的課程2成績信息: "); ? ? ? ? ? ? ? ? while (!scanf("%lf",&p1->course2)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? p1->avg=(p1->course1+p1->course2+p1->course3)/3.0; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 6: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生改正的課程3成績信息: "); ? ? ? ? ? ? ? ? while (!scanf("%lf",&p1->course3)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? p1->avg=(p1->course1+p1->course2+p1->course3)/3.0; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? case 7: ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入該學(xué)生全部要改正的信息: "); ? ? ? ? ? ? ? ? while (!scanf("%d %s %d %lf %lf %lf",&p1->id, p1->name, &p1->clas, &p1->course1, &p1->course2, &p1->course3)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入改正信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? p1->avg=(p1->course1+p1->course2+p1->course3)/3.0; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? if (cho == 1 || cho == 7) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (p1 == head) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? head = head->next; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else if (p1->next == NULL) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? p2->next = NULL; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? p2->next = p1->next; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? head = sinsert(head,p1); ? ? ? ? ? ? } ? ? ? ? ? ? printf(" ?學(xué)號(hào) ? 姓名 ? 班級(jí) ? ?課程1 ? ? 課程2 ? ?課程3 ? ?平均分 ?\n"); ? ? ? ? ? ? printf("—————————————————————————————————\n"); ? ? ? ? ? ? printf("%-7d %-7s %-7d %-5.2lf ? ?%-5.2lf ? ?%-5.2lf ? %-5.2lf\n", p1->id, p1->name, p1->clas, p1->course1, p1->course2, p1->course3, p1->avg); ? ? ? ? ? ? l = 0; ? ? ? ? ? ? printf(" ? 1.繼續(xù)修改其他學(xué)生信息\n"); ? ? ? ? ? ? printf(" ? 2.退出修改\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d",&k)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入序號(hào)有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? if (k == 1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入需要修改的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入修改信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? else if (k != 2) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入\n"); ? ? ? ? ? ? } ? ? ? ? ? ? if ((w = fopen("C:\\Desktop\\Tscore_new.txt", "wb+")) == NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("cannot open file\n"); ? ? ? ? ? ? ? ? exit(1); ? ? ? ? ? ? } ? ? ? ? ? ? p1=head; ? ? ? ? ? ? while(p1!=NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? fprintf(w,"%d %s %d %lf %lf %lf %lf \n", p1->id, p1->name, p1->clas, p1->course1, p1->course2,p1->course3,p1->avg); ? ? ? ? ? ? ? ? p1= p1->next; ? ? ? ? ? ? } ? ? ? ? ? ? fclose(w); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? k = 1; ? ? ? ? ? ? printf("找不到該學(xué)生信息,請(qǐng)重新輸入需要修改的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入修改信息有誤,請(qǐng)重新輸入: "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? while(k == 1); ? ? printf(" ? "); ? ? system("pause"); } struct Stu_score *delete_score(struct Stu_score *head) { ? ? int num,k; ? ? FILE *w; ? ? struct Stu_score *p1,*p2; ? ? if(head == NULL) ? ? { ? ? ? ? printf("沒有學(xué)生信息,結(jié)束刪除\n"); ? ? ? ? return(head); ? ? } ? ? printf("請(qǐng)輸入要?jiǎng)h除的學(xué)生學(xué)號(hào): "); ? ? while (!scanf("%d", &num)) ? ? { ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入學(xué)生學(xué)號(hào): "); ? ? ? ? fflush(stdin); ? ? } ? ? do ? ? { ? ? ? ? p1 = p2 = head; ? ? ? ? while (num != p1->id && p1->next != NULL) ? ? ? ? { ? ? ? ? ? ? p2 = p1; ? ? ? ? ? ? p1 = p1->next; ? ? ? ? } ? ? ? ? if (num == p1->id) ? ? ? ? { ? ? ? ? ? ? if (num == p1->id) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (p1->next == NULL && p1 == head) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? ? ? head = NULL; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else if (p1->next == NULL)//如果刪除完表空了 把表刪除 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? ? ? p2->next = NULL; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else if (head == p1) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? head = p1->next; ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? p2->next = p1->next; ? ? ? ? ? ? ? ? ? ? free(p1); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? printf("成功刪除學(xué)生信息\n"); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf("找不到該同學(xué)信息\n"); ? ? ? ? ? ? fflush(stdin); ? ? ? ? } ? ? ? ? if (head == NULL) ? ? ? ? { ? ? ? ? ? ? printf("沒有學(xué)生信息,結(jié)束刪除\n"); ? ? ? ? ? ? return(head); ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? printf(" ? 1.繼續(xù)刪除學(xué)生信息\n"); ? ? ? ? ? ? printf(" ? 2.結(jié)束刪除\n"); ? ? ? ? ? ? printf("請(qǐng)選擇: "); ? ? ? ? ? ? while (!scanf("%d",&k)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入選擇的序號(hào): "); ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? } ? ? ? ? ? ? if (k == 1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("請(qǐng)輸入要?jiǎng)h除的學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? ? ? while (!scanf("%d", &num)) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? printf("輸入有誤,請(qǐng)重新輸入學(xué)生學(xué)號(hào): "); ? ? ? ? ? ? ? ? ? ? fflush(stdin); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? else if (k != 2) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? k = 1; ? ? ? ? ? ? } ? ? ? ? ? ? if ((w = fopen("C:\\Desktop\\Tscore_new.txt", "wb+")) == NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? printf("cannot open file\n"); ? ? ? ? ? ? ? ? exit(1); ? ? ? ? ? ? } ? ? ? ? ? ? p1=head; ? ? ? ? ? ? while(p1!=NULL) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? fprintf(w,"%d %s %d %lf %lf %lf %lf \n", p1->id, p1->name, p1->clas, p1->course1, p1->course2,p1->course3,p1->avg); ? ? ? ? ? ? ? ? p1= p1->next; ? ? ? ? ? ? } ? ? ? ? ? ? fclose(w); ? ? ? ? } ? ? } ? ? while (k == 1); ? ? return(head); } struct Stu_score *add_score(struct Stu_score *head) { ? ? FILE *w; ? ? int i,num; ? ? struct Stu_score *p1; ? ? head = sinsert(head, NULL); ? ? printf("成功插入學(xué)生信息\n"); ? ? if ((w = fopen("C:\\Desktop\\Tscore_new.txt", "wb+")) == NULL) ? ? { ? ? ? ? printf("cannot open file\n"); ? ? ? ? exit(1); ? ? } ? ? p1=head; ? ? while(p1!=NULL) ? ? { ? ? ? ? fprintf(w,"%d %s %d %lf %lf %lf %lf\n",p1->id, p1->name, p1->clas, p1->course1, p1->course2,p1->course3,p1->avg); ? ? ? ? p1= p1->next; ? ? } ? ? fclose(w); ? ? return head; } void stu_statistics_score(struct Stu_score *head) { ? ? double cnt[3]; ? ? int i; ? ? double sum=0; ? ? struct Stu_score *p1; ? ? p1 = head; ? ? memset(cnt,0,sizeof(cnt)); ? ? printf("統(tǒng)計(jì)各課程不及格人數(shù)及所占百分比:\n"); ? ? while (1) ? ? { ? ? ? ? sum++; ? ? ? ? if(p1->course1<60) cnt[0]++; ? ? ? ? if(p1->course2<60) cnt[1]++; ? ? ? ? if(p1->course3<60) cnt[2]++; ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? break; ? ? ? ? p1 = p1->next; ? ? } ? ? printf("全體學(xué)生人數(shù):%.0lf人\n\n",sum); ? ? printf("課程1不及格人數(shù):%.0lf人 %5.2lf%%\n",cnt[0],(cnt[0]/sum)*100); ? ? printf("課程2不及格人數(shù):%.0lf人 %5.2lf%%\n",cnt[1],(cnt[1]/sum)*100); ? ? printf("課程3不及格人數(shù):%.0lf人 %5.2lf%%\n\n",cnt[2],(cnt[2]/sum)*100); } void course_statistics_score(struct Stu_score *head) { ? ? int i; ? ? int c1max=0,c2max=0,c3max=0; ? ? int c1min=1000,c2min=1000,c3min=1000; ? ? double sum1=0,sum2=0,sum3=0; ? ? double n=0; ? ? struct Stu_score *p1; ? ? p1 = head; ? ? printf("統(tǒng)計(jì)各課程最高分、最低分和平均分:\n"); ? ? while (1) ? ? { ? ? ? ? if(p1->course1<c1min) c1min=p1->course1; ? ? ? ? if(p1->course2<c2min) c2min=p1->course2; ? ? ? ? if(p1->course3<c3min) c3min=p1->course3; ? ? ? ? if(p1->course1>c1max) c1max=p1->course1; ? ? ? ? if(p1->course2>c2max) c2max=p1->course2; ? ? ? ? if(p1->course3>c3max) c3max=p1->course3; ? ? ? ? sum1+=p1->course1; ? ? ? ? sum2+=p1->course2; ? ? ? ? sum3+=p1->course3; ? ? ? ? n++; ? ? ? ? if (p1->next == NULL) ? ? ? ? ? ? break; ? ? ? ? p1 = p1->next; ? ? } ? ? printf("全體學(xué)生人數(shù):%.0lf人\n\n",n); ? ? printf("課程1最高分、最低分和平均分:%3d ?%3d ?%3.2lf\n",c1max,c1min,sum1/n); ? ? printf("課程2最高分、最低分和平均分:%3d ?%3d ?%3.2lf\n",c2max,c2min,sum2/n); ? ? printf("課程3最高分、最低分和平均分:%3d ?%3d ?%3.2lf\n\n",c3max,c3min,sum3/n); }
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 基于C語言實(shí)現(xiàn)學(xué)生管理系統(tǒng)
- c語言實(shí)現(xiàn)學(xué)生管理系統(tǒng)詳解
- C語言實(shí)現(xiàn)班級(jí)學(xué)生管理系統(tǒng)
- C語言不用鏈表完成學(xué)生管理系統(tǒng)(完整代碼)
- C語言單鏈表實(shí)現(xiàn)學(xué)生管理系統(tǒng)
- C語言實(shí)現(xiàn)學(xué)生管理系統(tǒng)
- C語言鏈表實(shí)現(xiàn)學(xué)生管理系統(tǒng)
- C語言實(shí)現(xiàn)簡(jiǎn)單學(xué)生管理系統(tǒng)
- C語言學(xué)生管理系統(tǒng)源碼分享
- C語言實(shí)現(xiàn)簡(jiǎn)易學(xué)生管理系統(tǒng)
相關(guān)文章
詳解C++中十六進(jìn)制字符串轉(zhuǎn)數(shù)字(數(shù)值)
這篇文章主要介紹了詳解C++中十六進(jìn)制字符串轉(zhuǎn)數(shù)字(數(shù)值)的相關(guān)資料,這里提供兩種實(shí)現(xiàn)方法,需要的朋友可以參考下2017-08-08華為機(jī)試題之統(tǒng)計(jì)單詞個(gè)數(shù)實(shí)例代碼
這篇文章主要介紹了華為機(jī)試題之統(tǒng)計(jì)單詞個(gè)數(shù)實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2017-05-05C語言中g(shù)etchar的用法以及實(shí)例解析
getchar()是stdio.h中的庫函數(shù),它的作用是從stdin流中讀入一個(gè)字符,下面這篇文章主要給大家介紹了關(guān)于C語言中g(shù)etchar的用法以及實(shí)例的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-03-03從匯編看c++中函數(shù)里面的static關(guān)鍵字的使用說明
c++中的static關(guān)鍵字使得函數(shù)里面的局部變量的存活期不在局限于函數(shù)里面,而是變?yōu)樵谡麄€(gè)程序生命期里面都有效2013-05-05opencv3/C++實(shí)現(xiàn)霍夫圓/直線檢測(cè)
今天小編就為大家分享一篇opencv3/C++實(shí)現(xiàn)霍夫圓/直線檢測(cè),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-12-12C++中priority_queue模擬實(shí)現(xiàn)的代碼示例
在c++語言中數(shù)據(jù)結(jié)構(gòu)中的堆結(jié)構(gòu)可以通過STL庫中的priority_queue 優(yōu)先隊(duì)列來實(shí)現(xiàn),這樣做極大地簡(jiǎn)化了我們的工作量,這篇文章主要給大家介紹了關(guān)于C++中priority_queue模擬實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2021-08-08