當前位置:首頁 » 考試成績 » 學生成績管理系統查找

學生成績管理系統查找

發布時間: 2020-12-23 04:56:14

⑴ 關於C++ 編寫一個簡單的學生成績管理系統.通過本系統能實現對學生成績記錄的顯示,查詢,修改添加和刪除

#include <iostream>
#include<fstream>
using namespace std;
const int N=5
;
class student
{
char n_name[10];
char n_numble[5];
char n_sex[3];
float score[4];//score[0]英語成績,score[1]數學成績,score[2]語文成績,score[3]平均分
public:
student();
student(char name[],char numble[],char sex[],float a,float b,float c);
student(student &s);
void input();//輸入學生信息:姓名,學號,性別,英語,數學,語文
float pj();//獲取平均分

void stu_delete(student stu[]);//刪除
void stu_find(student stu[]);
void dispaly();//顯示學生信息:姓名,學號,性別,英語,數學,語文,平均分
};
student::student()
{
strcpy(n_numble,"000");
strcpy(n_name,"noname");
strcpy(n_sex,"male");
score[0]=88;
score[1]=99;
score[2]=95;
score[3]=94;
}
student::student(char name[],char numble[],char sex[],float a,float b,float c)
{
strcpy(n_name,name);
strcpy(n_numble,numble);
strcpy(n_sex,sex);
score[0]=a;
score[1]=b;
score[2]=c;
score[3]=(score[0]+score[1]+score[2])/3.0;
}
student::student(student &s)
{
strcpy(n_name,s.n_name);
strcpy(n_numble,s.n_numble);
strcpy(n_sex,s.n_sex);
score[0]=s.score[0];
score[1]=s.score[1];
score[2]=s.score[2];
score[3]=(score[0]+score[1]+score[2])/3.0;

}
void student::input()
{
cout<<"輸入學生信息:"<<endl;
cout<<"請依次輸入姓名,學號,性別,英語,數學,語文"<<endl;
cin>>n_name>>n_numble>>n_sex>>score[0]>>score[1]>>score[2];
score[3]=(score[0]+score[1]+score[2])/3.0;
}

float student::pj()
{
return score[3];
}

void student::stu_delete(student stu[])
{
student t;
int i,k,j;
char d_numble[5];
cout<<"請輸入要刪除的學生學號:";
cin>>d_numble;
for(i=0;i<N+1;i++)
{
j=i;
k=strcmp(stu[i].n_numble,d_numble);
if(k==0&&i!=N)
{
for(;j<N;j++)
stu[j]=stu[j+1];
}
if(k==0&&i==N)
{
strcpy(stu[N].n_numble,"0000");
strcpy(stu[N].n_name,"noname");
strcpy(stu[N].n_sex,"男");
stu[N].score[0]=0;
stu[N].score[1]=0;
stu[N].score[2]=0;
stu[N].score[3]=0;
}
}
}
void student::stu_find(student stu[])
{
int i,k;
char d_numble[5];
cout<<"請輸入要查詢學生的學號:";
cin>>d_numble;
for(i=0;i<N+1;i++)
{
k=strcmp(stu[i].n_numble,d_numble);
if(k==0)
{
stu[i].dispaly();

}
}
}
void student::dispaly()
{
cout<<"姓名:"<<n_name<<" "<<"學號:"<<n_numble<<" "<<"性別:"<<n_sex<<" "<<"英語:"<<score[0]<<" "<<"數學:"<<score[1]<<" "<<"語文:"<<score[2]<<" "<<"平均分:"<<score[3]<<endl;
}
class manage_stu
{
//private:
student stu[N+1];//定義N+1名學生空間
public:
void input_stu();//輸入N名學生信息

void delete_stu();//刪除指定學號的學生信息
void find_stu();//查找指定學號的學生並顯示
void total_stu();//分別求每個人的總分
void sort_stu();//按總分高低排序,排序後的結果顯示並生成文件sortstu.txt
void display_stu();//顯示N名學生信息
};
void manage_stu::input_stu()//輸入N名學生信息
{
int i;
for(i=0;i<N;i++)
stu[i].input();
}
void manage_stu::delete_stu()//刪除指定學號的學生信息
{
student r;
r.stu_delete(stu);
}
void manage_stu::find_stu()//查找指定學號的學生並顯示
{
student t;
t.stu_find(stu);
}
void manage_stu::total_stu()//分別求每個人的總分
{
int i;
for(i=0;i<N+1;i++)
stu[i].pj();
}
void manage_stu::sort_stu()
{
int i,j;
student a;
for(i=0;i<N-1;i++)
{
for(j=i;j<N;j++)
{
if(stu[i].pj()<stu[j].pj())
{
a=stu[i];
stu[i]=stu[j];
stu[j]=a;
}
}
}
}
void manage_stu::display_stu()//顯示N名學生信息
{
student t;
int i;
for(i=0;i<N;i++)
stu[i].dispaly();
}
void main()
{

int i=1,c;
manage_stu s;
while(i)
{
cout<<"學生管理系統:"<<endl;
cout<<"1、錄入學生信息"<<N<<"名學生信息"<<endl;
cout<<"2、查找"<<endl;
cout<<"3、排序"<<endl;
cout<<"4、刪除"<<endl;
cout<<"5、顯示幾名學生信息"<<endl;
cout<<"6、退出系統"<<endl;
cout<<"請選擇(1--6):";
cin>>c;
switch(c)
{
case 1:s.input_stu();break;
case 2:s.find_stu();break;
case 3:s.sort_stu();break;
case 4:s.delete_stu();break;
case 5:s.display_stu();break;
case 6:i=0;
}
}
}

⑵ 學生成績管理系統

學生成績管理系統C代碼
/ *頭文件* /
#包括
包括
#包括 / *其他指令* /
包括中/ *字元串函數* /
/ *內存操作函數* /
/ *字元處理函數* /
包括 / *動態地址分配函數* /
定義:LEN大小(學生)
typedef結構中,學??生/ *定義結構數組,用於緩存數據* /
{字元數[6];
字元名稱[5];
得分[3];
int總和;
>浮動平均水平;
詮釋訂單
結構STU *下;
}的學生;

/ *函數原型* /
學生的init( );/ /初始化函數* /
詮釋MENU_SELECT的(); / *菜單函數* /
學生的create(); / *創建的鏈表* /
無效列印(學生*頭); / *顯示所有記錄* /
無效搜索(學生*頭); / *找到記錄* /
學生刪除(STUDENT *頭); / *刪除記錄* / />學生排序(學生頭); / *排序* /
學生(學生*頭,新的學生*); *插入/ *插入記錄* /
無效保存(的學生頭); / *保存文件* /
學生的load(); / *讀取文件* /

/ *主函數介面* /
主()
{的學生*頭,新的;
頭的init(); / *初始化鏈表頭的值是NULL * /
(;) / *循環無限* /
{開關(menu??_select())
{
案例1:頭= create()方法的突破;
案例2:列印(頭);休息;
案例3:搜索(頭);突破;
情況下,4頭=刪除(頭);突破;
情況下5頭排序(頭);突破;
案例6:頭插入(頭,與新的);打破; / *新的返回地址* /
案例7:保存(頭);
案例8:頭=負載(
案例9:退出);突破;(0)/ *如果菜單,返回值是年底的9個項目* /
}
}
}

/ *初始化函數* /
學生的init()
{
返回NULL; / *返回一個空指針* /
}
a>
/ *菜單選擇功能* /
menu_select

{N;
結構日期d / *定義的時間結構* / /> GETDATE(&D)/ *讀取系統日期,並把它在結構上D * /
printf的(「按任意鍵進入菜單......」); / *按任意鍵進入主菜單* /
的getch(); / *讀取從鍵盤輸入一個字元,但不顯示在屏幕上* /
clrscr(); / *清屏* / /> printf(「請********************************************* *********************************** \ n「);
printf(」請\ T \噸的\ n「);
printf(」請\ n \ t \ t學生成績管理系統\ n「);
printf(」請************ ************************* MENU ************************ *************** \ n「);
printf的(」\ t \ t \ T1輸入記錄\ n「); / *輸入學生記錄* / BR /> printf的(「\ t \ t \ T2列印記錄\ n」); / *顯示* /
printf的(「\ t \ t \ T3的搜索記錄名稱\ n」); / * * /
printf的(「\ t \ t \ T4。刪除記錄\ n」); / *刪除* /
printf的(「\ t \ t \ T5。排序,使新的文件\ n「); / *排序* / <br /輸出(」\ t \ t \ T6插入記錄到列表\ n「); / *插入* /
printf的(」\ t \ t \ T7保存的文件\ n「); / *保存* /
printf的(」\ t \ t \ T8負載的文件\ n「); / *讀* /
printf的(」\ t \ T \ T9退出\ n「); / *退出* /
printf的(」\ n \ t \ t胡嘿黌\ n「);
printf的(」****** ************************************************** ************************ \ n「);
printf的(」\ t \ t \ t \ t%d \ \%d的\ \%e\「,d.da_year,d.da_mon,d.da_day); / *顯示當前系統日期* /
做{
printf的(」\ n \ t \ t \拉幅機的選擇(1?9):「);
scanf的(」%d「,&N);
}(N 9)/ *如果該選項是不減肥9 * /
回報率(N); / *返回選項的數量,主要功能調用相應的函數* /

}
/ *輸入函數* /
學生創??建()
{I,S
學生頭= NULL,* P / *定義函數這個函數返回一個指針表頭指針* /
Clrscr();
(;)
{P =(學生)的malloc(LEN); / *打開了一個新的單元* / BR />(P)/ *如果指針p是空* /
{printf的(「\ Nout的記憶。」); / *輸出內存溢出* /
回報(頭); / *返回頭指針,下同* /
}
printf的(「請輸入NUM(0:列表結束):」);
scanf的(「%s」,P-> NUM);
(P->數[0] == '0')打破; / *如果第一個字元的學生數0輸入* /
printf(「請結束輸入姓名:「);
scanf的(」%s「,P->名稱);
printf(」請輸入%D分數\ n「); / *迅速啟動分型結果* /

= 0; / *計算每個學生的總成績,初始值為0 * /
(i = 0; I <3; i + +)/ * 3個療程周期的3倍* /
{
做{
printf的(「得分%D:」,i +1);
scanf的(「%d」的,普 - >得分[I]);
(P->得分[I] 得分[I]> 100)/ *確保得分在0至100之間* /
printf的(「數據錯誤,請重新輸入\ n」);
}而(P>得分[I] [I]> 100分);
= S + P->得分[I] / *堆積門的成績* /
}
P->總和= S / *節省的總成績* /
對平均= (浮)/ 3; / *首先轉換類型轉換s轉換為float類型,然後尋求的平均* /
P->訂單= 0; / *在此之前的值排序為0 * / BR /> P> =頭; / *頭節點作為一個新的輸入節點的後繼節點* /
頭= P / *新的輸入節點作為新的頭節點* /
}
a>回報(頭);
}

/ *顯示所有記錄函數* / >無效列印(學生頭)
{i = 0; / *統計記錄數* /
學生* P / *移動指針* /

Clrscr();
P =頭; / *初始的頭指針* / /> printf(「請\ n ************************************學生****** ****************************** \ n「);
printf(」請---- -------------------------------------------------- --------------------- \ n「); <br /輸出(」|記錄|編號|名稱| SC1 SC2 SC3 |森|大道|訂單| \ n「);
printf的(」------------------------------------ ------------------------------------------- \ n「); ...... />而(p! = NULL)
{
+ +;
printf的(「|%3D |%4 |%|%-4S 3D | 3D | 3D | %的3d |%4.2f |%-5d的| \「,
,對 - >數,對 - >名稱,對 - >分數[0],對 - >分數[1],對 - > [2分],P->總之,對平均,P->訂單);
P = P->下;
}
printf的(「------ -------------------------------------------------- ----------------------- \ n「);
printf的(」*************** *********************** END ************************** ************ \ n「);
}

/ *查找錄音功能* /
無效搜索(學生*頭) BR /> {STUDENT * p; / *移動指針* /
個char [5]; / *商店的名稱的字元數組* /
Clrscr();
scanf函數
printf的(「請輸入您的名字進行搜索。\ n」);(%S「,S);
P =頭; / *分配的頭指針P * /
而(STRCMP(P->名稱,s)&& P = NULL)/ *的名稱的記錄時不看,或指針的時空* /
P = P-> / *移動指針指向下一個節點* /
(p! = NULL)/ *如果指針不為空* /
{printf(「請\ n ******** ***************************** FOUND ******************** **************** \ n「);
printf(」請---------------------- -------------------------------------------------- ------- \ n「);
printf的(」|編號|名稱| SC1 SC2 | SC3 |森|大道|訂購| \ n「);
printf的(」 - -------------------------------------------------- --------------------------- \ n「);
printf的(」| 4 |%4S |%3D |%三維|%的3d |%的3d |%4.2f |%-5d的| \ N「,
對 - >數,對 - >名稱,對 - >分數[0],對 - >分數[1],對 - >分數[2],對 - >總和,對 - >平均,對 - >順序);
printf(「請------------------- -------------------------------------------------- --------- \ n「);
printf的(」***************************** ********** END ************************************** \ N「);
}
其他
printf的(」\ n該網頁的沒有NUM%的學生在名單上。\ n「); / *學生* /
}

/ *刪除記錄的函數* /
學生*頭*刪除(學生)

學生{N; * P1 * P2 / * P1是找到要刪除一個節點的指針,P2及其前體的指針* /
字元c的s [6] / [6]用來存儲學生數,c是用於輸入字母* / </ clrscr();
printf的(「請輸入刪除的民:」);
scanf的(「%s」);
P1 = P2 =頭; / * P1和P2富最初的頭指針* /
(STRCMP(P1-NUM)&& P1 = NULL)/ *當記錄數的學校不看,或指針不為空* / /> {P2 = P1 / * P1指針的值分配給P2 P1前體指針* /
P1 = P1->; / *點p1指針到下一條記錄* /
} BR />(STRCMP(P1->民)== 0)/ *學生ID * /
{printf的(「***************** ********************* FOUND **************************** ******** \ n「);
printf(」請------------------------------ ------------------------------------------------- \ N「);
printf的(」|編號|名稱| SC1 SC2 | SC3 |森|大道|在線訂單| \ n「);
printf的(」--------- -------------------------------------------------- -------------------- \ n「);
printf的(」| 4 |%4S |%3D | 3D | 3D | 3D |%4.2f%5D | \ n「,
P1->民,P1->名稱,P1->得分[0],P1 - > [1分],P1->得分[2] ,P1->總之,P1->平均,P1->訂單);
printf的(「-------------------------- -------------------------------------------------- --- \ n「);
printf(」請*********************************** **** END ************************************** \ n「); ...... /> printf的(「你確定要刪除的學生Y / N?」); / *提示你是否要刪除,輸入y刪除n退出* /
(;)
/> {scanf函數(「%C」,&C);
(C =='N'| | C =='N'); / *如果你不刪除,然後跳出循環* /
(C =='Y'| | C =='Y')
{
(P1 ==頭)/ * P1 ==頭,被刪除節點是第一個節點* /
頭= P1->下; / *第二個節點的地址給頭* /
其他
P2->下一個= P1-> /否則,請單擊節點地址被分配到前一個節點的地址* /
N = N-1; <br /輸出(「\ nNum%的學生已被刪除。\ n」,S); /> printf的(「不要忘記保存。\ n」); / *循環後已被刪除* /
}
}
} 其他
printf的(「\ n該網頁的沒有NUM%的學生在名單上。\ n」); /,找不到節點* /
回報(頭);
}

/ *排序函數* /
學生排序(學生頭)
{INT I = 0; / *保存排名* /
學生* P1, * P2 * T,*溫度; / *定義一個臨時指針* /
溫度=頭下; / *原來的下一個節點的指針表頭的頭指針* /
頭> = NULL; / *頭節點的新表的第一個節點* /
(temp! = NULL)/ *當原表不為空,進行排??序* /
{
T =溫度; / *取前表節點* /
TEMP =溫度 - >; / *原來的頭節點的指針向後* /
P1 =頭/頭*移動指針P1指針從頭開始* /
P2 =頭; / *移動指針P2為的P1前驅體的頭指針的初始值* /
而(平均平均&& P1 = NULL)/ *成績平均比??較* /
{
P2 = P1 / *點值小進行排序,新表指針落後* /
P1 = P1->下;
}
(P1 == P2)/ * P1 == P2,點值進行排序,應該排在第一個* / BR /> {
T-> = P1;進行排序的繼任者的p * /
頭= T / * / *新的頭節點進行排序點* /
}
的else / *進行排序點應插入在中間的位置p2和p1的,例如為p的空尾之間* /
{
叔 - >下一個= p1的; / * t的後繼是p1 * /
P2-> = T / * P2的繼任噸* /
}
}
P1 =頭; / *排序頭指針被分配到P1准備填寫的排名* /
(p1! = NULL)/ * p1是不是空的,下面的操作* /
{
+ +; / *節點數量* /
P1->訂單; / *分配的節點數量的排名* /
P1 = P1->; / *指針後移* /
}
printf的(「的排序是SUCESSFUL。\ n」排序;} / *成功* /
回報(頭);
}

/ *插入記錄功能* /
學生插入(學生頭STUDENT *新)
{STUDENT * P0,P1,P2;
整數N,SUM1;
P1 =頭/ * P1點的第一個節點* /
P0 =新/ * P0點要插入節點* /
printf的(「\ n請輸入一個新的記錄。\ n」) / *提示信息記錄* /
printf的(「請輸入數量:」);
scanf函數(「%s」的新數);
printf(「輸入的名稱:「);
scanf的(」%s「的新名);
printf的(」請輸入%d的分數。\ n「);
SUM1 = 0; / *保存新的得分紀錄,初始值為0 * /
為(i = 0; I <3; i + +)
{
做{
printf的(「得分%D:「,i +1);
scanf的(」%d「的,與新>得分[]);
(新 - >得分[I]> 100 | |新 - >得分[I] <0)
printf(「請數據錯誤,請重新輸入。\ n」);
}而(新 - >評分[我]> 100 | |新 - >評分[I] <0);
SUM1 = SUM1 +新 - >得分[I] / *累計門成績* /
}
新 - >金額= SUM1; /存款總額新的記錄* /
新的平均=()SUM1 / 3;
新訂單= 0;
(頭== NULL)/ *原鏈表為空表* /
{頭= P0,P0-> = NULL;} / *節點指出P0口作為頭節點* /
其他
{((P0->平均平均)&&(P1->!= NULL))
{P2 = P1 / P2點只是P1結點* /
P1 = P1->; / * P1落後節點* /
}
(P0->平均> = P1->平均)
{如果(頭== P1)頭= P0 / *插入到原來的第一個節點* / />其他P2-> = P0 / *在插入節點* /
P0-> = P1;}
其他
{P1->下一個= P0到P2點P0-> = NULL;} / *上的最後一個節點* /
}
N = N +1; / *節點數目加1 * /
頭排序(頭); / *調用sort函數的學生的成績重新排序* /
printf的(「,已插入\ nStudent%s的。\ n」,新名);
printf的(「不要忘記保存新的文件。\ n「);
回報(頭);
}

/ *將數據保存到文件函數* /
無效保存(學生*頭)
{FILE * FP; / *定義點文件指針* /
STUDENT * p; / *定義移動指針* /
字元,OUTFILE [10];
輸出(「請輸入OUTFILE名稱,例如C:\ \成績\ n」);
scanf的(「%s」,OUTFILE);
((FP =打開(OUTFILE,「WB」) )== NULL)/ *為輸出打開一個二進制文件,只寫* /
{
printf的(「無法打開文件\ n」);
回報; / *如果您無法打開返回菜單* /
}
printf的(「\ nSaving的文件... \ n」);
P =頭; / *移動指針從頭開始* /
而(p! = NULL)/ * p不為空* /
{
FWRITE(P,LEN,1,FP); / *寫的指針記錄* /
P = P->下; / *指針後移* /
}
FCLOSE(FP); / *關閉文件* /
printf的(「將文件保存成功!\ n「);
}

/ *從文件功能* /
學生中讀取數據負載()
{STUDENT * P1 * P2 *頭= NULL; / *定義記錄指針變數* /
FILE * FP / *定義指向文件的指針* /
字元的infile [10];
printf的(「輸入INFILE名稱,例如c:\ \成績\ n「);
scanf的(」%s「,infile中);
((FP =的FOPEN(INFILE,」包「))= = NULL)/ *打開一個二進制文件只讀* /
{
printf的(「無法打開文件\ n」);
回報(頭);
}
printf的(「\ n載入的文件!\ n」);
P1 =(學生)的malloc(LEN); / *開辟了一條新的單位* /
(P1 )
{
printf的(「內存不足!\ n」);
回報(頭);
}
頭= P1 / *適用於空間,作為頭指針* /

同時(!的feof(FP))/ *循環讀取數據,直到年底結束的文件* / {

(FREAD(P1,LEN,1,FP)= 1)打破; / *如果你不讀出的數據的循環* /
P1-> =(學生)的malloc(LEN); / *下一個結點打開空間* /
(P1->)
{
printf的(「內存不足!\ n」);
回報(頭); BR />}
P2 = P1 / P2點只是P1結點* /
P1 = P1->; / *指針回新讀入數據鏈當前的表* /
}
P2-> = NULL; / *最後一個節點的繼任指針為空* /
FCLOSE(FP);
輸出( 「你已經成功從文件中讀取數據!\ n」);
回報(頭);
}

⑶ 學生成績管理系統c

#include "stdio.h"
#include<conio.h>
#include<string.h>
#include<stdlib.h>
struct book{
char number[21];
char shuming[30];
int shuliang;
int jiage;
char zhuanye[20];
char zuozhe[26];
char chubanshe[20];
char beizhu[100];
struct book *next;
};

struct book *creat() /*創建鏈表*/
{
struct book *p,*head,*end;
head=end=p=(struct book *)malloc(sizeof(struct book));
printf("輸入教材編號為0結束輸入,每項信息都必須輸入內容。\n");
do
{
printf("\n教材編號:");
gets(p->number);
if(strcmp(p->number,"0")==0){ end->next=NULL; return head;}
end=p;
printf("\n教材名稱:");
gets(p->shuming);
printf("\n教材數量:");
scanf("%d",&p->shuliang);
printf("\n教材價格:");
scanf("%d",&p->jiage);
getchar();
printf("\n教材專業:");
gets(p->zhuanye);
printf("\n教材作者:");
gets(p->zuozhe);
printf("\n教材出版社:");
gets(p->chubanshe);
printf("\n備注:");
gets(p->beizhu);
p=(struct book *)malloc(sizeof(struct book));
end->next=p;
}while(1);

}

void save(struct book *head) /*保存鏈表*/
{FILE *fp;
struct book *p;
char filename[30];
int ch;
printf("請輸入「文件名.後綴」:");
scanf("%s",filename);
if((fp=fopen(filename,"r"))!=NULL)
{
printf("\n該文件已存在,是否覆蓋?1,是 2,否");
scanf("%d",&ch);
if(ch!=1)
return;
}
if((fp=fopen(filename,"w"))==NULL) { printf("\n文件保存失敗");getchar();return;}
p=head;
do{
fprintf(fp,"\n%s",p->number);
fprintf(fp,"\n%s",p->shuming);;
fprintf(fp,"\n%d",p->shuliang);
fprintf(fp,"\n%d",p->jiage);
fprintf(fp,"\n%s",p->zhuanye);
fprintf(fp,"\n%s",p->zuozhe);
fprintf(fp,"\n%s",p->chubanshe);
fprintf(fp,"\n%s",p->beizhu);
p=p->next;
}while(p!=NULL);
fprintf(fp," over");
printf("\n成功保存");
getchar();
getchar();
fclose(fp);
}

void print(struct book *head) /*輸出鏈表*/
{
struct book *p;
p=head;
if(p==NULL) { printf("未打開任何文件,無法顯示"); getch();return;}
do{
printf("\n\n教材編號:%s",p->number);
printf("\n教材名稱:%s",p->shuming);;
printf("\n數量:%d",p->shuliang);
printf("\n價格:%d",p->jiage);
printf("\n專業:%s",p->zhuanye);
printf("\n作者:%s",p->zuozhe);
printf("\n出版社:%s",p->chubanshe);
printf("\n備註:%s",p->beizhu);
p=p->next;
}while(p!=NULL);
}

struct book *openfile() /*打開文件*/
{struct book *p,*f,*head;
FILE *fp;
char filename[20];
printf("\n請輸入路徑,文件名,和後綴):");
scanf("%s",filename);
if((fp=fopen(filename,"r"))==NULL){ printf("\n文件找不到,請檢查是否有該文件和路徑是否正確");getchar();return NULL;}
head=f=p=(struct book *)malloc(sizeof(struct book));
fscanf(fp,"%s%s%d%d%s%s%s%s",p->number,p->shuming,&p->shuliang,&p->jiage,p->zhuanye,p->zuozhe,p->chubanshe,p->beizhu);
while(!feof(fp))
{ p=(struct book *)malloc(sizeof(struct book));
f->next=p;

fscanf(fp,"%s%s%d%d%s%s%s%s",p->number,p->shuming,&p->shuliang,&p->jiage,p->zhuanye,p->zuozhe,p->chubanshe,p->beizhu);
if(strcmp(p->number,"over")==0){ f->next=NULL; printf("\n文件打開成功,可以顯示此信息");getchar(); return head; }
f=p;
}

return head;
}

void namesort(struct book *head) /*按教材名稱排序*/
{ struct book *p,*t,*f,*h;
char ch[20];
int i;
h=t=f=p=head;
if(head==NULL) {printf("未打開任何文件");getchar();return; };
f=p->next;

for(p=head;p->next!=NULL;p=p->next)
{
for(t=head,f=t->next;t->next!=NULL;f=f->next,t=t->next)
{

if(strcmp(t->shuming,f->shuming)>0)
{
strcpy(ch,t->number );
strcpy(t->number,f->number);
strcpy(f->number,ch);

strcpy(ch,t->shuming );
strcpy(t->shuming,f->shuming);
strcpy(f->shuming,ch);

i=t->shuliang ;
t->shuliang=f->shuliang;
f->shuliang=i;

i=t->jiage ;
t->jiage=f->jiage;
f->jiage=i;

strcpy(ch,t->zhuanye);
strcpy(t->zhuanye,f->zhuanye);
strcpy(f->zhuanye,ch);

strcpy(ch,t->zuozhe);
strcpy(t->zuozhe,f->zuozhe);
strcpy(f->zuozhe,ch);

strcpy(ch,t->chubanshe);
strcpy(t->chubanshe,f->chubanshe);
strcpy(f->chubanshe,ch);

strcpy(ch,t->beizhu);
strcpy(t->beizhu,f->beizhu);
strcpy(f->beizhu,ch);

}

}
}
print(h);
}

void chubanshesort(struct book *head) /*按出版社排序*/
{ struct book *p,*t,*f,*h;
char ch[20];
int i;
h=t=f=p=head;
if(head==NULL) {printf("未打開任何文件");getchar();return; }
f=p->next;

for(p=head;p->next!=NULL;p=p->next)
{
for(t=head,f=t->next;t->next!=NULL;f=f->next,t=t->next)
{

if(strcmp(t->chubanshe,f->chubanshe)>0)
{
strcpy(ch,t->number );
strcpy(t->number,f->number);
strcpy(f->number,ch);

strcpy(ch,t->shuming );
strcpy(t->shuming,f->shuming);
strcpy(f->shuming,ch);

i=t->shuliang ;
t->shuliang=f->shuliang;
f->shuliang=i;

i=t->jiage ;
t->jiage=f->jiage;
f->jiage=i;

strcpy(ch,t->zhuanye);
strcpy(t->zhuanye,f->zhuanye);
strcpy(f->zhuanye,ch);

strcpy(ch,t->zuozhe);
strcpy(t->zuozhe,f->zuozhe);
strcpy(f->zuozhe,ch);

strcpy(ch,t->chubanshe);
strcpy(t->chubanshe,f->chubanshe);
strcpy(f->chubanshe,ch);

strcpy(ch,t->beizhu);
strcpy(t->beizhu,f->beizhu);
strcpy(f->beizhu,ch);

}

}
}
print(h);
}

void shumingsearch(struct book *head) /*按教材名稱查找*/
{ struct book *p;
char name[20];
int c;
if(head==NULL) {printf("未打開任何文件");getchar();return;}
printf("1,查找專業 2,查找教材名稱:");
scanf("%d",&c);
getchar();
if(c==2)
printf("請輸入要查找的教材名稱:");

else printf("請輸入要查找的專業:");
gets(name);
p=head;
do{ if(c==2)
if(strcmp(p->shuming,name)==0)
{
printf("教材編號:%s\n教材名稱:%s\n數量:%d\n價格:%d\n專業:%s\n作者:%s\n出版社:%s\n備註:%s\n",p->number,p->shuming,p->shuliang,p->jiage,p->zhuanye,p->zuozhe,p->chubanshe,p->beizhu);

}
if(c==1)
if(strcmp(p->zhuanye,name)==0)
{
printf("教材編號:%s\n教材名稱:%s\n數量:%d\n價格:%d\n專業:%s\n作者:%s\n出版社:%s\n備註:%s\n",p->number,p->shuming,p->shuliang,p->jiage,p->zhuanye,p->zuozhe,p->chubanshe,p->beizhu);

}
p=p->next;
}while(p!=NULL);
printf("查找完成");
return;
}

struct book *add(struct book *head) /*增加記錄*/
{ struct book *p,*e,*f,*h;
if(head==NULL) {printf("未打開任何文件");getchar(); return NULL;}
h=f=e=head;

p=(struct book *)malloc(sizeof(struct book));
printf("\n教材編號:");
gets(p->number);
printf("\n教材名稱:");
gets(p->shuming);
printf("\n數量:");
scanf("%d",&p->shuliang);
printf("\n價格:");
scanf("%d",&p->jiage);
getchar();
printf("\n專業:");
gets(p->zhuanye);
printf("\n作者:");
gets(p->zuozhe);
printf("\n出版社:");
gets(p->chubanshe);
printf("\n備注:");
gets(p->beizhu);

if(strcmp(f->number,p->number)>0) { p->next=f;h=p;printf("\n添加成功");return h;}
if(f->next==NULL) { f->next=p;p->next=NULL;printf("\n添加成功");return h;}
do{
if(f->next!=NULL)
if(strcmp(f->number,p->number)>0)
{
e->next=p;p->next=f;printf("\n添加成功");return h;
}

if(f->next==NULL)
{
f->next=p;
p->next=NULL;
printf("\n添加成功");
return h;
}

f=f->next;
e=e->next;
}while(1);
}

struct book *delet(struct book *head) /*刪除記錄*/
{ struct book *p,*e;
char num[20];
if(head==NULL) {printf("未打開任何文件");getchar();return NULL;}
printf("請輸入要刪除的教材編號:");
scanf("%s",num);
p=e=head;
if(strcmp(p->number,num)==0) { head=head->next; print(head);return head;}
else p=p->next;
do{

if(strcmp(p->number,num)==0)
{
if(p->next!=NULL)
e->next=p->next;
if(p->next==NULL) e->next=NULL;
print(head);
return head;
}
p=p->next;
e=e->next;
}while(p!=NULL);
printf("搜索完畢,未找到該記錄");
return head;
}

struct book *change(struct book *head) /*修改記錄*/
{ struct book *p;
char num[20];
if(head==NULL) {printf("未打開任何文件");getchar();return NULL;}
printf("請輸入要修改的教材編號:");
scanf("%s",num);
getchar();
p=head;
do{
if(strcmp(p->number,num)==0)
{
printf("教材編號:%s\n教材名稱:%s\n數量:%d\n價格:%d\n專業:%s\n作者:%s\n出版社:%s\n備註:%s\n",p->number,p->shuming,p->shuliang,p->jiage,p->zhuanye,p->zuozhe,p->chubanshe,p->beizhu);
printf("\n教材編號:");
gets(p->number);
printf("\n教材名稱:");
gets(p->shuming);
printf("\n數量:");
scanf("%d",&p->shuliang);
printf("\n價格:");
scanf("%d",&p->jiage);
getchar();
printf("\n專業:");
gets(p->zhuanye);
printf("\n作者:");
gets(p->zuozhe);
printf("\n出版社:");
gets(p->chubanshe);
printf("\n備注:");
gets(p->beizhu);
printf("修改成功");
return head;
}
p=p->next;
}while(p!=NULL);
printf("未找到要修改的記錄");
return head;
}

int mima()
{ FILE *fp;
char mima1[20],mima2[20];

if((fp=fopen("mima","r"))==NULL)

{ printf("尚未設置密碼請輸入:");
scanf("%s",mima1);
printf("請再次輸入密碼:");
scanf("%s",mima2);
if(strcmp(mima1,mima2)!=0) { printf("兩次密碼不一樣");return 0;}
else {
fp=fopen("mima","w");
fprintf(fp,"%s",mima1);
printf("密碼設置成功");
return 1;
}
}

printf("請輸入初始化密碼:");
scanf("%s",mima1);
fscanf(fp,"%s",mima2);
if(strcmp(mima1,mima2)==0)
{
printf("密碼正確");
printf("請輸入要刪除的文件名:");
scanf("%s",mima1);
if(remove(mima1)==0)
{
printf("刪除成功");
getchar();
return 1;
}
else {
printf("刪除失敗,請檢查是否存在該文件或路徑是否正確");
getchar();
return 0;
}
}
else {
printf("密碼錯誤");
getchar();
return 0;
}

}

void main()
{
struct book *head=NULL;
char i;

printf(" 88888888888 \n");
printf(" d88888888888b \n");
printf(" d88888 88888b \n");
printf(" d88P 88b \n");
printf(" 888' `88b \n");
printf(" 88P Y88 \n");
printf(" 88 88\n");
printf(" 88 88\n");
printf(" 88 88\n");
printf(" 88 88\n");
printf(" 88 88\n");
printf(" 88 ,aa. ,aa. 88 \n");
printf(" 88 d88b d88b 88 \n");
printf(" ,=88 Y88P Y88P 88=, \n");
printf(" ,d88P' `' _aa_ `' `Y88b, \n");
printf(" 88P' (8888) `Y88 ad88888b \n");
printf(" 88 ~^^~ 88 d88Y Y8b\n");
printf(" Yb._ _.d8 d8Y 88\n");
printf(" d88888888ba888=,. .,=8888 d88 88 \n");
printf(" ★☆88P Y88~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~★☆\n");
printf(" ★☆ 88 88 ★☆\n");
printf(" ★☆88 88 歡迎使用本教材系統,按任意鍵進入系統 ★☆\n");
printf(" ★☆ 8b,___,d8 ★☆\n");
printf(" ★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆\n");

getch();

system("cls");
do{
printf(" ☆★☆★☆★ 教材管理系統 ☆★☆★☆★\n");
printf("m--菜單 h--幫助");
printf("\n請輸入命令:");
i=getch();
if(i=='h')
{ printf("\n1,錄入教材信息的時候,每一個項目都必須輸入相應的內容。\n2,修改,增加,刪除,查找記錄前必須先打開一個文件,修改完後必須記得保存教材信息。\n3,必須使用正確的路徑打開文件,建議保存文件時候不用輸入路徑(此時是默認路徑,即保存在程序目錄下。)");
getch();
break;
}
if(i=='m')
break;
system("cls");
}while(i!='m'||i!='h');

system("cls");
do{
printf(" ☆★☆★☆★ 教材管理系統 ☆★☆★☆★\n");

printf("┌————-———┐\n");
printf("│1,錄入教材信息│\n│2,顯示教材信息│\n│3,打開一個記錄│\n│4,編輯一個記錄│\n│5,保存教材信息│\n│6,查找記錄 │\n│s,初始化系統 │\n│e,退出系統 │\n");
printf("└———————-┘\n");
printf("\n請輸入功能編號:");
i=getch();
system("cls");
switch(i)
{
case '1': head=creat();save(head);break;
case '2': print(head);break;
case '3': head=openfile();break;
case '4': system("cls");
printf("┌————-———┐\n");
printf("│1,增加一個記錄│\n");
printf("│2,刪除一個記錄│\n");
printf("│3,修改一個記錄│\n");
printf("└———————-┘\n");
i=getch();
switch(i)
{
case '1':
head=add(head);break;
case '2':
head=delet(head);break;
case '3': head=change(head);break;
default: break;
}
break;
case '5': save(head);break;
case '6': shumingsearch(head);break;
case 's': mima();break;
case 'e': exit(0);
default :break;
}
system("cls");
}while(1);
}

我想這個程序包含了你那個成績管理系統的全部要求,但我這個是教材管理系統我想改一下就可以了,具體如何改就要看樓主的天賦咯,呵呵。參考一下吧

⑷ c語言學生成績管理系統程序設計,有添加,查找,刪除,輸出,修改,排序等功能!!!

同學你參照下,有不懂的,網路上Hi我
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
struct sc
{
int chinese;
int maths;
int english;
};

typedef struct node
{
int num;
char name[20];
struct sc score;
struct node *next;
}st;

int menu()//菜單
{
int choice;
do{
("cls");
printf("\t1.input the messega about a student\n");

printf("\t2.insect a messega of a new student\n");

printf("\t3.look for the messega\n");

printf("\t4.dellect the messega\n");

printf("\t5.arranging base on the number of learning\n");

printf("\t6.output all the messega\n");

printf("\t7.arranging base on all scores\n");

printf("\t8.exit the system\n");

printf("\tplease input your choice:");

scanf("%d",&choice);
}while(choice>7&&choice<1);
return choice;
}

st *create()//創建鏈表
{
st *head,*p,*tail;
char c;
head=tail=NULL;
while(c!='n'&&c!='N')
{

p=(st *)malloc(sizeof(st));
p->next=NULL;
printf("\t\tplease input the number of learning:");
scanf("%d",&p->num);

printf("\t\tplease input the name:");
scanf("%s",p->name);

printf("\t\tplease input the score of chinese:");
scanf("%d",&p->score.chinese);

printf("\t\tplease input the score of maths:");
scanf("%d",&p->score.maths);

printf("\t\tplease input the score of english:");
scanf("%d",&p->score.english);
if(head==NULL)

head=tail=p;
else
{
tail->next=p;
tail=p;
}

printf("\t\tcontinue or stop(Y/N):");
scanf("%s",&c);
}
return head;
}

st *arrange(st *head)// 以學號排名
{
st *p,*q;
int t,i=1,j,chinese,maths,english;
char name[20];
p=head;
if(head==NULL)
printf("\t\tNoting to arrange\n");
else
{
do
{
j=1;
while(p->next!=NULL)
{
q=p->next;
if(p->num>=q->num)
{
t=p->num;
p->num=q->num;
q->num=t;

strcpy(name,p->name);
strcpy(p->name,q->name);
strcpy(q->name,name);

chinese=p->score.chinese;
p->score.chinese=q->score.chinese;
q->score.chinese=chinese;

maths=p->score.maths;
p->score.maths=q->score.maths;
q->score.maths=maths;

english=p->score.english;
p->score.english=q->score.english;
q->score.english=english;

}
p=q;
j++;
}
p=head;
i++;
}while(i!=j);
}
return head;
}

st *arrangeall(st *head)//以總分排名
{
st *p,*q;
int t,i=1,j,chinese,maths,english;
char name[20];
p=head;
if(head==NULL)
printf("\t\tNoting to arrange\n");
else
{
do
{
j=1;
while(p->next!=NULL)
{
q=p->next;
if(p->score.chinese+p->score.maths+p->score.english<q->score.chinese+q->score.maths+q->score.english)
{
t=p->num;
p->num=q->num;
q->num=t;

strcpy(name,p->name);
strcpy(p->name,q->name);
strcpy(q->name,name);

chinese=p->score.chinese;
p->score.chinese=q->score.chinese;
q->score.chinese=chinese;

maths=p->score.maths;
p->score.maths=q->score.maths;
q->score.maths=maths;

english=p->score.english;
p->score.english=q->score.english;
q->score.english=english;

}
p=q;
j++;
}
p=head;
i++;
}while(i!=j);
}
return head;
}

st *insect(st *head,st *t)//插入學生的信息
{
st *p,*q;
p=head;
if(head==NULL)
printf("\tThe list is empty\n");
else
{

if(t->num==p->num)
{
head=t;
t->next=p;
}
else
{
while(p->next!=NULL)
{
q=p->next;
if(p->num<=t->num&&q->num>=t->num)
{
t->next=q;
p->next=t;
}
p=q;
}
p->next=t;
}
}
return head;
}

void output(st *head)//輸出所以學生的信息
{
st *p;
int i=0;
float sum1=0,sum2=0,sum3=0;
p=head;
if(head==NULL)
{
printf("\tThere is nothing \n");
return;
}
else
{
printf("\tnumber name chinese maths english allscores\n");
while(p)
{
printf("\t %d ",p->num);
printf(" %s ",p->name);
printf(" %d ",p->score.chinese);
printf(" %d ",p->score.maths);
printf(" %d ",p->score.english);
printf("%6d",p->score.chinese+p->score.maths+p->score.english);
printf("\n");
p=p->next;
}

p=head;
while(p)// avrege scores
{
sum1+= p->score.chinese;
sum2+=p->score.maths;
sum3+=p->score.english;
p=p->next;
i++;
}
printf("\tarvege %.2f %.2f %.2f %.2f \n",sum1/i,sum2/i,sum3/i,(sum1+sum2+sum3)/i);

}
system("pause");
}

st *dellect(st *head,st *d)//刪除學生的信息
{
st *p,*q;
char c;
p=head;
if(!(strcmp(p->name,d->name)))
{
head=p->next;
free(p);
}
else
{
while((strcmp(p->name,d->name))&&p->next!=NULL)
{
q=p;
p=q->next;
}
if(!(strcmp(p->name,d->name)))
{
printf("do you want to delete %S ?(Y/N):",p->name);
scanf("%s",&c);

if(c=='y'||c=='Y')
{
q->next=p->next;
free(p);
}
}
else
printf("\tThere isn't this name\n");
}

return head;
}

void find(st *head,st *s)//查找學生的信息
{
st *p,*q;
p=head;
if(head==NULL)
printf("\tThe list is empty\n");
else
{

while((strcmp(p->name,s->name))!=0&&p->next!=NULL)
{

q=p;
p=q->next;
}

if((strcmp(p->name,s->name))==0)

{
printf("\t %d ",p->num);
printf(" %s ",p->name);
printf(" chinese=%d ",p->score.chinese);
printf(" maths=%d ",p->score.maths);
printf(" english=%d ",p->score.english);
printf("all=%d",p->score.chinese+p->score.maths+p->score.english);
printf("\n");
}
else
printf("\tThe name is missing\n");
}
system("pause");
}

void main()//主函數
{
st *head,*t,*s,*d;
int choice;

for(;;)
{
choice=menu();
switch(choice)
{

case 1:
head=create();
break;

case 2:
t=(st *)malloc(sizeof(st));
t->next=NULL;
printf("\t\tplease input the number of learning:");
scanf("%d",&t->num);

printf("\t\tplease input the name:");
scanf("%s",t->name);

printf("\t\tplease input the score of chinese:");
scanf("%d",&t->score.chinese);

printf("\t\tplease input the score of maths:");
scanf("%d",&t->score.maths);

printf("\t\tplease input the score of english:");
scanf("%d",&t->score.english);

head=insect(head,t);
break;

case 4:

d=(st *)malloc(sizeof(st));
d->next=NULL;
printf("\twhice student do you want to dellect?please input the name:");
scanf("%s",d->name);
head=dellect(head,d);
break;

case 3:

s=(st *)malloc(sizeof(st));
s->next=NULL;
printf("\twhice student do you want to look for?please input the name:");
scanf("%s",s->name);
find(head,s);
break;

case 5:
head=arrange(head);//number
break;

case 6:
output(head);
break;
case 7:
head=arrangeall(head);//score
break;

case 8:
printf("\t\tThank you,goodbye\n");
exit(0);
}
}

}

⑸ 菜鳥做一個學生成績管理系統,已經把學生信息保存在文本中,如何根據輸入學號,查找某一學生的信息。謝謝

我給你改了兩個錯誤現在可以運行了,不知道還有沒有其他邏輯錯誤,自己進一步修改吧。
第一個,你在排序那個程序里一個for循環不加,這個錯誤有些幼稚,不像能寫出這種程序的人該犯的。
第二個錯誤,main主函數里if判斷語句判等的時候用了賦值號,應該改成==
建議:你要學會調試,這種編譯不過調試一下子就可以找到是排序函數的哪句話出錯了。調試用F9標記,F5調試F10安步走,F11進入內層函數
#include<iostream>
#include<string>
using namespace std;
struct student //定義一個學生結構體
{
string name;
string sex;
int num;
int math;
int english;
int chinese;
int sum; //個人總分
float pingjun; //個人平均分
};
student stu[3];
int n; //全局變數
void input(student *p, int n) //輸入模塊
{
int i;
double SUM,PINGJUN;
p=&stu[0];
for(i=0;i<n; i++, p++)
{
cout<<"請依次輸入第"<<i+1<<"個學生的姓名,性別,學號,數學分數,英語分數語文分數"<<endl;
cin>>(*p).name;
cin>>(*p).sex;
cin>>(*p).num;
cin>>(*p).math;
cin>>(*p).english;
cin>>(*p).chinese;
(*p).sum=(*p).math+(*p).english+(*p).chinese; //求個人總分
(*p).pingjun=((*p).math+(*p).english+(*p).chinese)/3; //個人平均分
SUM=SUM+(*p).sum; //班級總分
PINGJUN=SUM/3; //班級平均分

} cout<<"班級總分"<<SUM<<endl;
cout<<"班級平均分"<<PINGJUN<<endl;
}
void output(student *p, int n) //輸出學生信息
{
for(int i=0;i<n;i++,p++)
{
cout<<"第"<<i+1<<"個學生的信息"<<"\n";
cout<<"姓名"<<p[i].name<<"\n";
cout<<"性別"<<p[i].sex<<"\n";
cout<<"數學分數"<<p[i].math<<"\n";
cout<<"英語分數"<<p[i].english<<"\n";
cout<<"語文分數"<<p[i].chinese<<"\n";
cout<<"個人總分"<<p[i].sum<<"\n";
cout<<"個人平均分"<<p[i].pingjun<<"\n";
}
}
void paixu(student *p, int n) //排序模塊
{
int i, j, t;
string g;
for(i=0; i<n-1; i++)
{
for(j=0; j<n-i; j++)
{
if(p[j].sum<p[j+1].sum)
{
g=p[j].name; p[j].name=p[j+1].name; p[j+1].name=g;
g=p[j].sex; p[j].sex=p[j+1].sex; p[j+1].sex=g;
t=p[j].math; p[j].math=p[j+1].math; p[j+1].math=t;
t=p[j].english;p[j].english=p[j+1].english;p[j+1].english=t;
t=p[j].chinese; p[j].chinese=p[j+1].chinese; p[j+1].chinese=t;
t=p[j].sum; p[j].sum=p[j+1].sum; p[j+1].sum=t;
}
}
}
}
void chaozhao(student *p,int n) //查找模塊
{
int xh;
while(n==0)
{
cout<<"沒有記錄,請先輸入學生信息"<<endl;
break;
}
if(n!=0)
{
cout<<"輸入您要查找的學生學號"<<endl;
cin>>xh; //輸入學號
}
if(xh==p[n].num)
{
cout<<"姓名"<<p[n].name<<"\t";
cout<<"性別"<<p[n].sex<<"\t";
cout<<"學號"<<p[n].num<<"\t";
cout<<"數學分數"<<p[n].math<<"\t";
cout<<"英語分數"<<p[n].english<<"\t";
cout<<"語文分數"<<p[n].chinese<<"\t";
cout<<"總分"<<p[n].sum<<"\t";
}
else
cout<<"沒有找到您要查找的學生"<<endl;
}
void main() //主函數
{
student *q=&stu[0];
paixu(q,3);
int i;
cout<<"*……………………管理系統……………………*"<<endl;
cout<<"請選擇你需要的操作:"<<endl;
cout<<"(1)輸入學生信息"<<endl;
cout<<"(2)按學號查找"<<endl;
cout<<"(3)顯示所有學生信息"<<endl;
cin>>i;
if(i==1)
input(q,3);
if(i==2)
chaozhao(q,3);
if(i==3)
output(q,3);
}

⑹ 求一個學生成績管理系統

不用指針那就只能用數組了,學生信息包括哪些?姓名、學號......

⑺ 學生成績管理系統

#include "stdafx.h"
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
// 循環列表結構 head->[,->next]...[data0,->next][data1,->next]...[datan,->head]
struct SCORE
{
int courseId;
int score;
SCORE *pnext;
};
struct STU_SCORE
{
char name[16];
int stuId;
SCORE *scoreHead;//學生課程成績列表
struct STU_SCORE *pnext;
STU_SCORE(int ID,char names[])
{
int len=strlen(names);
for(int i=0;i<len;++i)
name[i]=names[i];
name[len]='\0';
stuId=ID;
}
};
int mainMenu();
int stuReg(STU_SCORE *pHead);
int selCourse(STU_SCORE *pHead);
int inputData(STU_SCORE *pHead);
int scoreSort(STU_SCORE *pHead);
int scoreQuery(STU_SCORE *pHead);
int modify(STU_SCORE *pHead);
enum MAIN_CMD{REG,SEL=1,INPUT,QUERY,MODI,EXIT};
int main(int argc, char* argv[])
{
STU_SCORE *head=( STU_SCORE *)malloc(sizeof(STU_SCORE));
head->stuId=-1;
head->pnext=head;
while(1)
{
int cmd=mainMenu();
switch(cmd)
{
case REG:
stuReg(head);
break;
case SEL:
selCourse(head);
break;
case INPUT:
inputData(head);
break;
case QUERY:
scoreQuery(head);
break;
case MODI:
modify(head);
break;
case EXIT:
return 0;
}
}
return 0;
}
int mainMenu()
{
system("cls");
cout<<"\t\t《學生成績管理系統》\n";
cout<<" \t\t[0]新生注冊\n";
cout<<" \t\t[1]選課登記\n";
cout<<" \t\t[2]學生成績輸入\n";
cout<<" \t\t[3]成績查詢\n";
cout<<" \t\t[4]修改成績\n";
cout<<" \t\t[5]退出\n";
cout<<"命令? ";
int cmd;
cin>>cmd;
return cmd;
}
//新生注冊:建立學生信息鏈表,從鍵盤輸入學生姓名學號,插入到鏈表中。
int stuReg(STU_SCORE *pHead)
{
cout<<"注意:新生注冊學號不能重復!\n";
start:
cout<<"學號\t\t姓名\n";
int ID;
char StudentName[20];
cin>>ID;
while(ID>0)
{
cin>>StudentName;
STU_SCORE *newStu=new STU_SCORE(ID,StudentName);
newStu->scoreHead=new SCORE();
newStu->scoreHead->pnext=newStu->scoreHead;
STU_SCORE*q=pHead->pnext,*p=pHead;
while(q!=pHead)
{
p=q;
if(q->stuId<newStu->stuId)
q=q->pnext;
else
break;
}
p->pnext=newStu;
newStu->pnext=q;
cin>>ID;
}
int cnt=0;
STU_SCORE*q=pHead->pnext;
while(q!=pHead)
{
q=q->pnext;
cnt++;
}
cout<<"學生資料庫共有"<<cnt<<"個記錄"<<endl;
cout<<"繼續新的注冊?";
char c;
cin>>c;
if(c=='y'||c=='Y')goto start;
return 0;

}
//學生選課
int selCourse(STU_SCORE *pHead)
{
start:
int cid;
cout<<"課程號:";
cin>>cid;
cout<<"輸入選擇該課程的學生學號:\n";
int stuId;
cin>>stuId;
while(stuId>0)
{
STU_SCORE *pStu=pHead->pnext;

while(pStu!=pHead)//鏈表已有記錄
{
if(pStu->stuId==stuId)//有該學號
{
bool be=false;
SCORE *pcourse=pStu->scoreHead->pnext;
while(pcourse!=pStu->scoreHead)//已有選課
{
if(pcourse->courseId==cid)
{
be=true;////已有該選課
break;
}
pcourse=pcourse->pnext;
}
if(!be)
{ //還沒有選此課程
SCORE *pNewcourse=(SCORE *)malloc(sizeof(SCORE));
pNewcourse->courseId=cid;
SCORE*q=pStu->scoreHead->pnext;
pStu->scoreHead->pnext=pNewcourse;
pNewcourse->pnext=q;
}
}
pStu=pStu->pnext;
}
cin>>stuId;
}
int count=0;
STU_SCORE *pStu=pHead->pnext;
while(pStu!=pHead)//鏈表已有記錄
{
SCORE *pcourse=pStu->scoreHead->pnext;
while(pcourse!=pStu->scoreHead)
{
if(pcourse->courseId==cid)
{
count++;
}
pcourse=pcourse->pnext;
}
pStu=pStu->pnext;
}
cout<<"共有"<<count<<"個學生選此課程\n";
cout<<"繼續新的選課輸入?";
char c;
cin>>c;
if(c=='y'||c=='Y')goto start;
return 0;
}
//學生成績輸入
int inputData(STU_SCORE *pStuHead)
{
int count;
start:
count=0;
cout<<"課程號:";
int cid;
cin>>cid;
STU_SCORE *pStu=pStuHead->pnext;
while(pStu!=pStuHead)//if鏈表已有學生記錄
{
SCORE *pcourse=pStu->scoreHead->pnext;
while(pcourse!=pStu->scoreHead)
{
if(pcourse->courseId==cid)
{
cout<<"學號:"<<pStu->stuId<<" 姓名:"<<pStu->name;
cout<<" 成績:";
if(pcourse->score>=0)
cout<<"已輸入";
else
{
cin>>pcourse->score;
count++;
}
break;
}
pcourse=pcourse->pnext;
}
pStu=pStu->pnext;
}
if(count==0)
cout<<"該課程無學生選!\n";
else
cout<<cid<<"課程成績已輸入完成!"<<"\n";
cout<<"繼續其他課程成績輸入?";
char c;
cin>>c;
if(c=='y'||c=='Y')goto start;
return 0;
}
//課程成績查詢
int scoreQuery(STU_SCORE *pStuHead)
{
start:
int ID;
cout<<"學號:"<<endl;
cin>>ID;
STU_SCORE*pStu=pStuHead->pnext;
while(pStu!=pStuHead)
{
if(pStu->stuId==ID)
{
cout<<"姓名:"<<pStu->name<<"\t"<<"成績:"<<endl;
SCORE*pcourse=pStu->scoreHead->pnext;
while(pcourse!=pStu->scoreHead)
{
cout<<"課程號:"<<pcourse->courseId<<"\t"<<"成績:"<<pcourse->score<<endl;
pcourse=pcourse->pnext;
}
break;
}
pStu=pStu->pnext;
}
if(pStu==pStuHead)
{
cout<<"查無此人"<<endl;
}
cout<<"繼續查詢?";
char c;
cin>>c;
if(c=='y'||c=='Y')
goto start;
return 0;
}
//課程成績修改
int modify(STU_SCORE *pStuHead)
{
start:
int ID;
cout<<"學號:";
cin>>ID;
STU_SCORE*pStu=pStuHead->pnext;
while(pStu!=pStuHead)
{
if(pStu->stuId==ID)
{
int cid;
cout<<"課程號:";
cin>>cid;
SCORE*pcourse=pStu->scoreHead->pnext;
while(pcourse!=pStu->scoreHead)
{
if(pcourse->courseId==cid)
{
int rescore;
cout<<"原成績:"<<pcourse->score<<"\t"<<"成績修改為:";
cin>>rescore;
pcourse->score=rescore;
goto ask;
}
pcourse=pcourse->pnext;
}
if(pcourse==pStu->scoreHead)
{
cout<<"此人沒有選擇該課程。"<<endl;
goto ask;
}
}
pStu=pStu->pnext;
}
if(pStu==pStuHead)
{
cout<<"查無此人"<<endl;
}
ask:
cout<<"繼續修改?";
char c;
cin>>c;
if(c=='y'||c=='Y')
goto start;

return 0;
}

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919