資源簡介
這個學生成績管理系統,由本人親自編寫,經過調試運行沒有問題,總體設計(主要功能模塊)
★ 學生信息載入模塊
★ 學生信息創建模塊
★ 學生信息查詢模塊
★ 學生信息修改模塊
★ 學生信息統計模塊
★ 學生信息顯示模塊
★ 學生信息保存模塊
本程序采用鏈表的形式處理學生信息,所以用結構體儲存學生的信息,每個函數模塊都相互獨立,源代碼簡單易懂,可以方便的刪除、修改、添加模塊,便于根據各種情況對程序升級,以完成任務。
感謝使用啊!
代碼片段和文件信息
#include?“iostream.h“
#include?“string.h“
#include?“malloc.h“
#include“stdlib.h“
#include?“fstream.h“
#include“stdio.h“
#include“iomanip.h“??
#include“conio.h“
?
#define?NULL?0
#define?LEN?sizeof(struct?STUDENT)
struct?STUDENT
{
long?number;
char?name[20];
char?sex[10];
int?age;
int?mathematicsRecord;
int?englishRecord;
int?chineseRecord;
int?physicalRecord;
????int?cRecord;
int?xuanxiuRecord;
double?average;
struct?STUDENT?*next;
};
struct?STUDENT?*?head=NULL;
void?LoadData();
void?SaveData();
void?Add();
void?Input();
void?Show();
void?FindName();
void?FindNumber();
void?FindClass();
void?Modify();
void?Del();
void?Sort();
void?FindStudentAverage();
void?FindClassAverage();
void?AboutMe();
void?LoadData(){
????char?filename[20];?
cout<<“請輸入你要讀取的文件名:?“;?
cin>>filename;?
ifstream?fin(filenameios::in);?
if(!fin)
cout<<“文件打不開?!“< else?{?
struct?STUDENT?*p1*p2;
p1=p2=(struct?STUDENT?*)malloc(LEN);
fin>>p1->number>>p1->name>>p1->sex
???>>?p1->age?>>?p1->chineseRecord?
???>>?p1->englishRecord?>>?p1->mathematicsRecord
???>>?p1->physicalRecord>>p1->cRecord?
???>>?p1->xuanxiuRecord?;
int?n=0;
while(1){
if(fin.eof())
break;
n++;
????????if(n==1)
head=p1;
????????else
????????????p2->next=p1;
????????????p2=p1;
????????????p1=(struct?STUDENT?*)malloc(LEN);
fin>>p1->number>>p1->name>>p1->sex
???????>>?p1->age?>>?p1->chineseRecord?
???????>>?p1->englishRecord?>>?p1->mathematicsRecord
???????>>?p1->physicalRecord>>p1->cRecord?
???????>>?p1->xuanxiuRecord?;
}
????????????p2->next=NULL;
cout<<“文件已讀取成功!“< }
fin.close();?
cout<<“顯示如下。“< }?
void?SaveData()?//保存函數?
{?
char?filename[20];
cout<<“請輸入文件名:?“;?
cin>>filename;?
ofstream?fout(filename);?
if(!fout)
cout<<“文件不能打開!“< else?
{?
struct?STUDENT?*p;
p=head;
do{
????????fout?<number?<name?<sex<age
?????<chineseRecord??<englishRecord?< ?????<mathematicsRecord?<physicalRecord?<cRecord?
?<xuanxiuRecord< ?????????p=p->next;
}while(p?!=?NULL);
}
cout<<“保存成功!“< cout<<“將返回上一級。“< fout.close();?
getchar();?
}?
int?n=0;
void?Input(){
struct?STUDENT?*p1*p2;
char?flag=‘y‘;
p1=p2=(struct?STUDENT?*)malloc(LEN);
cout?<“請按照以下順序,輸入您要輸入的學生信息:“< cout?< ?< <????cin?>>?p1->number?>>?p1->name?>>p1->sex
>>?p1->age?>>?p1->chineseRecord?
>>?p1->englishRecord?>>?p1->mathematicsRecord
>>?p1->physicalRecord>>p1->cRecord?
>>?p1->xuanxiuRecord?;
while(flag==‘y‘){
n++;
????????if(n==1)
- 上一篇:哈工大軟件工程碩士C輔導題
- 下一篇:數據結構迷宮算法源碼+實驗報告
評論
共有 條評論