學籍管理系統c語言課程
⑴ c語言課程設計 學生學籍信息管理系統 我是大一的 實在是難啊 不會 誰能幫忙做下謝謝啦
建議自己做做吧,這東西始終都得學會和練習。
⑵ c語言課程設計學籍管理系統
這個是我曾經做的,上面功課和你的不一樣,把漢字改下就行了,還有那個人數,人數和排名最後一名數字一樣,你運行一下就清楚了
#include<stdio.h>
#include<malloc.h>
#define M "%-6s%-6d%-6d%-6d%-6d%-6d%-7d%-6d\n"
#define H p->name,p->num,p->grade.Escore,p->grade.Mscore,p->grade.Cscore,p->grade.Pscore,p->grade.Allscore,p->grade.Allrank
typedef struct score{
int Escore;
int Mscore;
int Cscore;
int Pscore;
int Allscore;
int Allrank;
}Sco;
typedef struct student{
char name [20];
int num;
struct score grade;
struct student *next;
}*stu;
struct student *Create(struct student *head)
{
int i,n;
printf("請輸入學生個數;");
scanf("%d",&n);
printf("請輸入信息和成績\n");
printf("姓名,學號,英語,高數,C語言,體育:");
printf("\n");
stu p,q;
p=q=(stu)malloc(sizeof(student));
head=p;
for(i=0;i<n;i++)
{
p->next=q;
p=q;
scanf("%s%d%d%d%d%d",q->name,&q->num,&q->grade.Escore,&q->grade.Mscore,&q->grade.Cscore,&q->grade.Pscore);
q->grade.Allscore=q->grade.Escore+q->grade.Mscore+q->grade.Cscore+q->grade.Pscore;
q=(stu)malloc(sizeof(student));
}
p->next=NULL;
return head;
}
struct student *Change(struct student *head)
{
int n,i,k;
stu p;
p=head;
printf("請輸入要修改的學號:");
scanf("%d",&i);
printf("1.英語 2.高數 3.C語言 4.體育\n");
printf("請輸入要修改的成績:");
scanf("%d",&n);
while(p)
{
if(i==p->num)
switch(n)
{
case 1:
printf("請輸入英語分數:");
scanf("%d",&k);
p->grade.Escore=k;
break;
case 2:
printf("請輸入高數分數:");
scanf("%d",&k);
p->grade.Mscore=k;
break;
case 3:
printf("請輸入C語言分數:");
scanf("%d",&k);
p->grade.Cscore=k;
break;
case 4:
printf("請輸入體育分數:");
scanf("%d",&k);
p->grade.Pscore=k;
break;
}
if(i==p->num) break;
if(p->next)
p=p->next;
}
p->grade.Allscore=p->grade.Escore+p->grade.Mscore+p->grade.Cscore+p->grade.Pscore;
return head;
}
struct student *Insert(struct student *head)
{
stu p,q;
p=q=(stu)malloc(sizeof(student));
p=head;
printf("請輸入姓名和學號:\n");
scanf("%s%d",q->name,&q->num);
printf("請輸入英語,高數,C語言,體育成績:\n");
scanf("%d%d%d%d",&q->grade.Escore,&q->grade.Mscore,&q->grade.Cscore,&q->grade.Pscore);
q->grade.Allscore=q->grade.Escore+q->grade.Mscore+q->grade.Cscore+q->grade.Pscore;
while(p->next)
{
p=p->next;
}
p->next=q;
p=p->next;
p->next=NULL;
return head;
}
struct student *Delet(struct student *head)
{
stu p,q,m;
int n;
printf("請輸入要刪除的學號:");
scanf("%d",&n);
p=head;
if(n==p->num)
{
q=p;
head=p->next;
free(p);
}
else
{
q=p->next;
while(q)
if(q->next==NULL&&n==q->num)
{
m=q;
free(q);
p->next=NULL;
q=NULL;
}
else if(q->next!=NULL&&n==q->num)
{
p->next=q->next;
free(q);
q=NULL;
}
else
{
if(q->next!=NULL)
{
p=q;
q=q->next;
}
}
}
return head;
}
void Look(struct student *head)
{
stu p;
int n,i,k;
p=head;
printf("1.按學號查找 2.按分數查找\n");
printf("請輸入查找的類別:");
scanf("%d",&n);
if(n==1)
{
printf("請輸入要查找的學號:");
scanf("%d",&i);
while(p)
{
if(i==p->num)
{
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名\n");
printf(M,H);
}
if(i==p->num) break;
if(p->next)
p=p->next;
}
}
if(n==2)
{
printf("1.英語 2.高數 3.C語言 4.體育 5.總分\n");
printf("請輸入要查找的課程:");
scanf("%d",&i);
switch(i)
{
case 1:
printf("請輸入要查找的英語最低分數:");
scanf("%d",&k);
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名\n");
while(p)
{
if(k<=p->grade.Escore)
printf(M,H);
p=p->next;
}
break;
case 2:
printf("請輸入要查找的高數最低分數:");
scanf("%d",&k);
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名\n");
while(p)
{
if(k<=p->grade.Mscore)
printf(M,H);
p=p->next;
}
break;
case 3:
printf("請輸入要查找C語言語最低分數:");
scanf("%d",&k);
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名\n");
while(p)
{
if(k<=p->grade.Cscore)
printf(M,H);
p=p->next;
}
break;
case 4:
printf("請輸入要查找的體育最低分數:");
scanf("%d",&k);
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名\n");
while(p)
{
if(k<=p->grade.Pscore)
printf(M,H);
p=p->next;
}
break;
case 5:
printf("請輸入要查找的總分最低分數:");
scanf("%d",&k);
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名\n");
while(p)
{
if(k<=p->grade.Allscore)
printf(M,H);
p=p->next;
}
break;
}
}
}
struct student *Rank(struct student *head,struct student *p,int j)
{
int i;
stu q;
i=p->grade.Allscore;
q=head;
while(q)
{
if(q->grade.Allscore>i)
j++;
if(!q->next)break;
q=q->next;
}
p->grade.Allrank=j;
while(p)
{
if(!p->next)break;
{
p=p->next;
Rank(head,p,1);
}
}
return head;
}
void Rankshow(struct student *head,int j)
{
int i;
stu p,q;
q=head;
p=head;
i=j;
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名\n");
while(q)
{
while(p)
if(i==p->grade.Allrank)
{
printf(M,H);
p=p->next;
}
else
p=p->next;
p=head;
i++;
if(!q->next)break;
q=q->next;
}
}
void show(struct student *head)
{
stu p;
printf("姓名 學號 英語 高數 C語言 體育 總成績 排名");
printf("\n");
p=head;
while(p)
{
printf(M,H);
p=p->next;
}
}
void main()
{
int n;
struct student *head,*p;
stu L;
printf("綜合素質測評系統\n");
printf("1.數據錄入\n");
printf("2.數據修改\n");
printf("3.插入操作\n");
printf("4.刪除操作\n");
printf("5.查找操作\n");
printf("6.排序操作\n");
printf("7.數據顯示\n");
printf("0.退出系統\n");
printf("請輸入操作:");
scanf("%d",&n);
while(n!=0)
{
switch(n)
{
case 0:
break;
case 1:
L=Create(head);
Rank(L,L,1);
printf("請輸入操作:");
break;
case 2:
Change(L);
Rank(L,L,1);
printf("請輸入操作:");
break;
case 3:
L=Insert(L);
Rank(L,L,1);
printf("請輸入操作:");
break;
case 4:
L=Delet(L);
Rank(L,L,1);
printf("請輸入操作:");
break;
case 5:
Look(L);
printf("請輸入操作:");
break;
case 6:
Rank(L,L,1);
Rankshow(L,1);
printf("請輸入操作:");
break;
case 7:
show(L);
printf("請輸入操作:");
break;
}
scanf("%d",&n);
}
}
⑶ 課程設計 C語言學籍管理系統!!!
給你看個我寫的班費管理系統,跟你這個比較類似,你改下就好了
#include<iostream>
#include<string>
#include<vector>
#include <fstream>
#include<sstream>
using namespace std;
class student
{
public:
student(string ,string ,string ,string );
string getSex(){return _sex;};
string getName(){return _name;};
string getID(){return _id;};
string getmoney(){return _money;};
void setMoney(string a){_money=a;};
void deleted(){_id="deleted";_name="deleted";_sex="deleted";_money="deleted";};
void setName(string);
void save();
void print();
private:
string _id;
string _name;
string _sex;
string _money;
string _total;
};
student::student(string id, string name, string sex,string money)
{
_id=id;_name=name;_sex=sex;
_money=money;
}
void student::save()
{
ofstream outf;
outf.open("myfile.txt",ios::app);
outf<<_id
<<"\t"<< _name
<<"\t"<<_sex
<<"\t"<<_money<<endl;
outf.close();
}
void student::print()
{
cout<<_id
<<"\t\t"<< _name
<<"\t\t"<<_sex
<<"\t\t"<<_money<<endl;
}
void printMenu(void)
{
cout<<"-------------class fee management system--------------"<<endl;
cout<<"| |"<<endl;
cout<<"| author:XY |"<<endl;
cout<<"| www.hdxuyi.cn |"<<endl;
cout<<"|----------------------------------------------------|"<<endl;
cout<<"| |"<<endl;
cout<<"| 1.Increase the student records |"<<endl;
cout<<"| 2.Delete student records |"<<endl;
cout<<"| 3.The total of class fee |"<<endl;
cout<<"| 4.search the class fee |"<<endl;
cout<<"| 5.view all class fee |"<<endl;
cout<<"| 6.add one class fee |"<<endl;
cout<<"| 0.exit |"<<endl;
cout<<"| |"<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<"make your choice:"<<endl;
}
void addstudent();//添加學生信息
void delstudent();//刪除學生信息
void selstudent();//查詢學生信息
void selall();//查詢所有信息
void total();//班費總額
void addmoney();//增加某個學生的班費(實為更新操作)
bool isinfile=false;//判斷是否讀取過txt
vector<student> stu;//全局對象student
int main()
{
int order=0;
printMenu();
cin>>order;
while(order!=0)
{
switch(order)
{
case 1:addstudent();printMenu();cin>>order;break;
case 2:delstudent();printMenu();cin>>order;break;
case 3:total();printMenu();cin>>order;break;
case 4:selstudent();printMenu();cin>>order;break;
case 5:selall();printMenu();cin>>order;break;
case 6:addmoney();printMenu();cin>>order;break;
default:break;
}
}
cout<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<"thank you for using the system~"<<endl;
cout<<"------------------------------------------------------"<<endl;
}
void infile()//讀取txt
{
if (isinfile==false)
{
stu.clear();
string tmp_id,tmp_name,tmp_sex,tmp_money;
int time =0;
string lines,field;
ifstream infile("myfile.txt");
while (getline (infile, lines))
{
istringstream stream(lines);
while(stream>>field)
{
switch(time)
{
case 0:tmp_id = field;time=1;break;
case 1:tmp_name = field;time=2;break;
case 2:tmp_sex = field;time=3;break;
case 3:tmp_money = field;time=0;
stu.push_back(student(tmp_id,tmp_name,tmp_sex,tmp_money));break;
}
}
}
isinfile==true;
infile.close();
}
}
void addstudent()
{
string tmp_id;
string tmp_name;
string tmp_sex;
string tmp_money;
cout<<"Insert-->ID:";
cin>>tmp_id;
cout<<"Insert-->Name:";
cin>>tmp_name;
cout<<"Insert-->Sex:";
cin>>tmp_sex;
cout<<"Insert-->Money:";
cin>>tmp_money;
student(tmp_id,tmp_name,tmp_sex,tmp_money).save();
cout<<"save success!"<<endl;
isinfile=false;
}
void selall()
{
infile();
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
(*iter).print();
}
cout<<"------------------------------------------------------"<<endl;
}
cout<<endl;
}
void delstudent()
{
infile();
string search_name;
string search_id;
cout<<"delete---->id:"<<endl;
cin>>search_id;
cout<<"delete---->name:"<<endl;
cin>>search_name;
bool isFind=false;
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search_name&&(*iter).getID()==search_id)
{
isFind=true;
stu.erase(iter);
}
}
//重新將刪除後的集合寫入txt
vector<student>::iterator iter1=stu.begin();
vector<student>::iterator iter1_end=stu.end();
ofstream outf;
outf.open("myfile.txt");
for(;iter1!=iter1_end;iter1++)
{
outf<<(*iter1).getID()
<<"\t"<<(*iter1).getName()
<<"\t"<<(*iter1).getSex()
<<"\t"<<(*iter1).getmoney()<<endl;
}
outf.close();
cout<<"delete success!"<<endl;
}
if(!isFind)
{
cout<<"Can't find this student!"<<endl;
}
cout<<endl;
}
void total()
{
infile();
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<"------------------------------------------------------"<<endl;
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
(*iter).print();
}
cout<<"------------------------------------------------------"<<endl;
}
cout<<endl;
}
void selstudent()
{
infile();
string search;
cout<<"search---->id or name:"<<endl;
cin>>search;
bool isFind=false;
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<"------------------------------------------------------"<<endl;
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search||(*iter).getID()==search)
{
isFind=true;
(*iter).print();
}
}
cout<<"------------------------------------------------------"<<endl;
}
if(!isFind)
{
cout<<"Can't find this student!"<<endl;
}
cout<<endl;
}
void addmoney()
{
infile();
string search;
string update;
cout<<"search---->id or name:"<<endl;
cin>>search;
bool isFind=false;
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search||(*iter).getID()==search)
{
(*iter).print();
isFind=true;
cout<<"update---->new class fee:"<<endl;
cin>>update;
(*iter).setMoney(update);
}
}
//重新將修改後的集合寫入txt
vector<student>::iterator iter1=stu.begin();
vector<student>::iterator iter1_end=stu.end();
ofstream outf;
outf.open("myfile.txt");
for(;iter1!=iter1_end;iter1++)
{
outf<<(*iter1).getID()
<<"\t"<<(*iter1).getName()
<<"\t"<<(*iter1).getSex()
<<"\t"<<(*iter1).getmoney()<<endl;
}
outf.close();
cout<<"update success!"<<endl;
}
if(!isFind)
{
cout<<"Can't find this student!"<<endl;
}
cout<<endl;
}
⑷ C語言設計一個學生學籍管理系統,要求文件形式保存,且用到鏈表
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//鏈表結點結構體聲明
typedefstructsubjects
{
charname[20];
floatscore;
}sub;
typedefstructstudent
{
intnum;
charname[20];
subsubject[3];
structstudent*next;
}stu,*pstu;
#defineSIZEsizeof(stu)
//函數申明
pstuLoadInfo();
voidPrintMenu();
pstuAddStu(pstu);
pstuDeleStu(pstu);
pstuRwrStu(pstu);
voidFindStu(pstu,char);
voidCount(pstu,char*,float,float);
voidRank(pstu,char*);
voidSaveQuit(pstu);
//主函數
intmain()
{
floatscore1,score2;
charn,j;
charsubname[20];
pstuhead,ptr;
head=LoadInfo();
ptr=head->next;
//創建菜單,進入選擇循環
while(1)
{
PrintMenu();
printf("請輸入您的選擇編號:");
scanf("%d",&n);
getchar();
switch(n)
{
case1:
{
system("cls");
j=0;
while(4!=j)
{
printf("歡迎進入信息管理版塊! ");
printf("