資源簡介
C++學籍管理系統,網上看到的,供大家一起共同分享學習。
代碼片段和文件信息
#include?
#include?
#include?
#include??
#include?
#include?
typedef?struct?STU{
char?name[20];
char?num[10];
int?grade1;//3種不同成績?
int?grade2;
int?grade3;
float?ave;//均分?
struct?STU?*next;
}STU;
STU?*head;
void?creathead();//創建表頭?
STU?*?mallocnode();//申請新節點?
int?insertonenode(STU?*t);//把節點移到鏈表尾部?
void?readfile();//讀入文件?
void?savefile();//存檔?
int?getinformation(STU?*t);//增加一個信息?
int?outputinformation(STU?*t);//輸出一個節點的信息?
int?sort();?//按學號從小到大排序?
void?outputall();?//輸出所有信息?
int?output_name();??//按姓名輸出信息?
int?output_num();?//按學號輸出學生信息?
int?scaning();?//屏幕人機互動函數?
int?del_single();?//按單一學號刪除學生?
int?chang_single();?//按學號修改學生?
int?del_more();//按學號范圍刪除?
int?main()
{
creathead();
readfile();
scaning();
}
int?scaning()?//屏幕人機互動函數?p
{
int?a;
STU?*p;
while(1)
{
start:
system(“cls“);
printf(“***********************學生學籍管理系統*****************************\n“);?
printf(“1.\t增加學生\n“);
printf(“2.\t刪除學生\n“);
printf(“3.\t輸出所有學生信息\n“);
printf(“4.\t查詢學生信息\n“);
printf(“5.\t修改學生信息\n“);
printf(“6.\t存檔\n“);
printf(“7.\t退出系統\n“);
a=getch();
while(a>‘7‘||a<‘1‘)
{
system(“cls“);
printf(“錯誤的選項“);
getch();
goto?start;
}
switch(a)
{
case?‘1‘:{
system(“cls“);
?p=mallocnode();
getinformation(p);
insertonenode(p);
break;}
case?‘2‘:{
system(“cls“);
printf(“***********************學生學籍管理系統*****************************\n“);?
printf(“\t1.按學號刪除“);
printf(“\t2.按學號區間刪除\n“);
int?c;
c=getch();
switch(c)
{
case?‘1‘:del_single();getch();break;
case?‘2‘:del_more();getch();break;
}
break;
}
case?‘3‘:{
system(“cls“);
outputall();
getch();?
break;
}
case?‘4‘:{
system(“cls“);
printf(“***********************學生學籍管理系統*****************************\n“);?
printf(“\t1.按學號查詢“);
printf(“\t2.按姓名查詢“);
int?b;
b=getch();
switch(b)
{
case?‘1‘:{
system(“cls“);
printf(“請輸入學號:“);
output_num();
getch();
break;
}
case?‘2‘:{
system(“cls“);
printf(“請輸入姓名:“);
output_name();
getch();
break;
}
}
break;
}
case?‘5‘?:{
system(“cls“);
chang_single();
getch();
break;
}
case?‘6‘:{
system(“cls“);
savefile();
getch();
free(head);
break;
}?
case?‘7‘:{
exit(0);
break;
}?
}
}
return?0;
}
void?creathead()//創建表頭?
{
STU?*p;
p=(STU*)malloc(sizeof(struct?STU));
p->next=NULL;
head=p;
}
STU?*?mallocnode()//建立一個新節點?
{
STU?*p;
p=(STU*)malloc(sizeof(STU));
if?(p==NULL)
return?NULL;
int?i;
for(i=0;i<20;i++)
p->name[i]=‘\0‘;
for(i=0;i<10;i++)
p->num[i]=‘\0‘;
p->grade1=0;
p->grade2=0;
p->grade3=0;
p->ave=0.0;
p->next=NULL;
return?p;
}
int?insertonenode(STU?*t)//把節點移到鏈表尾部?
{
STU?*p;
p=head;
while(p->next)
{
p=p->next;
- 上一篇:VC++ 多光譜影像處理
- 下一篇:井字棋用C語言寫的源代碼
評論
共有 條評論