① 用c語言設計學生學籍管理系統
#include
#include
/*定義學生結構體*/
struct Student
{
char ID[20];
char Name[20];
float Mark1;
float Mark2;
float Mark3;
float Average;
};
/*聲明學生數組及學生數量*/
struct Student students[1000];
int num=0;
/*求平均值*/
float Avg(struct Student stu)
{
return (stu.Mark1+stu.Mark2+stu.Mark3)/3;
}
/*通過學號返回數組下標*/
int Student_SearchByIndex(char id[])
{
int i;
for (i=0;i<num;i++)
{
if (strcmp(students[i].ID,id)==0)
{
return i;
}
}
return -1;
}
/*通過姓名返回數組下標*/
int Student_SearchByName(char name[])
{
int i;
for (i=0;i<num;i++)
{
if (strcmp(students[i].Name,name)==0)
{
return i;
}
}
return -1;
}
/*顯示單條學生記錄*/
void Student_DisplaySingle(int index)
{
printf("%10s%10s%8s%8s%8s%10s\n","學號","姓名","成績","成績","成績","平均成績");
printf("-------------------------------------------------------------\n");
printf("%10s%10s%8.2f%8.2f%8.2f%10.2f\n",students[index].ID,students[index].Name,
students[index].Mark1,students[index].Mark2,students[index].Mark3,students[index].Average);
}
/*插入學生信息*/
void Student_Insert()
{
while(1)
{
printf("請輸入學號:");
scanf("%s",&students[num].ID);
getchar();
printf("請輸入姓名:");
scanf("%s",&students[num].Name);
getchar();
printf("請輸入成績:");
scanf("%f",&students[num].Mark1);
getchar();
printf("請輸入成績:");
scanf("%f",&students[num].Mark2);
getchar();
printf("請輸入成績:");
scanf("%f",&students[num].Mark3);
getchar();
students[num].Average=Avg(students[num]);
num++;
printf("是否繼續?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*修改學生信息*/
void Student_Modify()
{
//float mark1,mark2,mark3;
while(1)
{
char id[20];
int index;
printf("請輸入要修改的學生的學號:");
scanf("%s",&id);
getchar();
index=Student_SearchByIndex(id);
if (index==-1)
{
printf("學生不存在!\n");
}
else
{
printf("你要修改的學生信息為:\n");
Student_DisplaySingle(index);
printf("-- 請輸入新值--\n");
printf("請輸入學號:");
scanf("%s",&students[index].ID);
getchar();
printf("請輸入姓名:");
scanf("%s",&students[index].Name);
getchar();
printf("請輸入成績:");
scanf("%f",&students[index].Mark1);
getchar();
printf("請輸入成績:");
scanf("%f",&students[index].Mark2);
getchar();
printf("請輸入成績:");
scanf("%f",&students[index].Mark3);
getchar();
students[index].Average=Avg(students[index]);
}
printf("是否繼續?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*刪除學生信息*/
void Student_Delete()
{
int i;
while(1)
{
char id[20];
int index;
printf("請輸入要刪除的學生的學號:");
scanf("%s",&id);
getchar();
index=Student_SearchByIndex(id);
if (index==-1)
{
printf("學生不存在!\n");
}
else
{
printf("你要刪除的學生信息為:\n");
Student_DisplaySingle(index);
printf("是否真的要刪除?(y/n)");
if (getchar()=='y')
{
for (i=index;i<num-1;i++)
{
students[i]=students[i+1];//把後邊的對象都向前移動
}
num--;
}
getchar();
}
printf("是否繼續?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*按姓名查詢*/
void Student_Select()
{
while(1)
{
char name[20];
int index;
printf("請輸入要查詢的學生的姓名:");
scanf("%s",&name);
getchar();
index=Student_SearchByName(name);
if (index==-1)
{
printf("學生不存在!\n");
}
else
{
printf("你要查詢的學生信息為:\n");
Student_DisplaySingle(index);
}
printf("是否繼續?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*按平均值排序*/
void Student_SortByAverage()
{
int i,j;
struct Student tmp;
for (i=0;i<num;i++)
{
for (j=1;j<num-i;j++)
{
if (students[j-1].Average<students[j].Average)
{
tmp=students[j-1];
students[j-1]=students[j];
students[j]=tmp;
}
}
}
}
/*顯示學生信息*/
void Student_Display()
{
int i;
printf("%10s%10s%8s%8s%8s%10s\n","學號","姓名","成績","成績","成績","平均成績");
printf("-------------------------------------------------------------\n");
for (i=0;i<num;i++)
{
printf("%10s%10s%8.2f%8.2f%8.2f%10.2f\n",students[i].ID,students[i].Name,
students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Average);
}
}
/*將學生信息從文件讀出*/
void IO_ReadInfo()
{
FILE *fp;
int i;
if ((fp=fopen("Database.txt","rb"))==NULL)
{
printf("不能打開文件!\n");
return;
}
if (fread(&num,sizeof(int),1,fp)!=1)
{
num=-1;
}
else
{
for(i=0;i<num;i++)
{
fread(&students[i],sizeof(struct Student),1,fp);
}
}
fclose(fp);
}
/*將學生信息寫入文件*/
void IO_WriteInfo()
{
FILE *fp;
int i;
if ((fp=fopen("Database.txt","wb"))==NULL)
{
printf("不能打開文件!\n");
return;
}
if (fwrite(&num,sizeof(int),1,fp)!=1)
{
printf("寫入文件錯誤!\n");
}
for (i=0;i<num;i++)
{
if (fwrite(&students[i],sizeof(struct Student),1,fp)!=1)
{
printf("寫入文件錯誤!\n");
}
}
fclose(fp);
}
/*主程序*/
void main()
{
int choice;
IO_ReadInfo();
while(1)
{
/*主菜單*/
printf("\n------ 學生成績管理系統------\n");
printf("1. 增加學生記錄\n");
printf("2. 修改學生記錄\n");
printf("3. 刪除學生記錄\n");
printf("4. 按姓名查詢學生記錄\n");
printf("5. 按平均成績排序\n");
printf("6. 退出\n");
printf("請選擇(1-6):");
scanf("%d",&choice);
getchar();
switch(choice)
{
case 1:
Student_Insert();
break;
case 2:
Student_Modify();
break;
case 3:
Student_Delete();
break;
case 4:
Student_Select();
break;
case 5:
Student_SortByAverage();
Student_Display();
break;
case 6:
exit(0);
break;
}
IO_WriteInfo();
}
}
② 用c語言編寫學生信息管理系統
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#define N 200
int input(struct Student stu[N]);
void save(struct Student stu[N],int n);
int load(struct Student stu[N]);
void output(struct Student stu[N],int n);
int insert(struct Student stu_save[],int n);
void sort(struct Student stu_save[],int n);
void find(struct Student stu_save[],int n);
int delete_stu(struct Student stu_save[],int n);
typedef struct Student
{
char num[20];
char name[20];
char sex;
int age;
float score[3];
float tolscore;
float ave;
}STU;
int main()
{
int total=0,a;
STU stu[N];
printf("☆☆☆☆☆學籍管理系統☆☆☆☆☆\n\n");
do{
printf("\n**********************************\n");
printf("1-導入學生信息\n2-載入學生信息\n3-保存學生信息\n4-按學號插入學生\n5-給學生排序\n6-查找學生\n7-刪除學生\n8-輸出當前學生數據\n9-退出\n");
printf("**********************************\n");
printf("請按鍵選擇:");
scanf("%d",&a);
switch(a)
{
case 1:
total=input(stu);
break;
case 2: total=load(stu);break;
case 3:save(stu,total);break;
case 4: total+=insert(stu,total);break;
case 5:sort(stu,total);break;
case 6:find(stu,total);break;
case 7:total-=delete_stu(stu,total);break;
case 8:output(stu,total);break;
case 9:exit(0);break;
default:printf("輸入錯誤,請重新輸入!\n");break;
}
//system("cls");
}while(1);
}
int input(struct Student stu[])
{
int i,j,n;
float sum;
printf("請輸入要導入的學生人數\n");
scanf("%d",&n);
printf("請輸入學生的學號、姓名、性別、年齡及三門課成績\n");
for(i=0;i<n;i++)
{
scanf("%s",stu[i].num);
scanf("%s",stu[i].name);
scanf(" %c",&stu[i].sex); //%c前的空格用於接收上一個字元串後的空格、回車、製表符,etc
scanf("%d",&stu[i].age);
sum=0;
for(j=0;j<3;j++)
{
scanf("%f",&stu[i].score[j]);
sum+=stu[i].score[j];
}
stu[i].tolscore=sum;
stu[i].ave=sum/3.0f;
}
return (n);
}
void save(struct Student stu[],int n)
{
FILE *fp;
int i;
char filename[20];
printf("請輸入文件名:");
scanf("%s",filename);
if(strchr(filename,'.')==NULL)
strcat(filename,".dat");
if((fp=fopen(filename,"wb"))==NULL)
{
printf("Cannot open this file\n");
system("pause");
return;
}
fwrite(&n,sizeof(int),1,fp);
for(i=0;i<n;i++)
fwrite(&stu[i],sizeof(struct Student),1,fp);
fclose(fp);
printf("保存成功!");
system("pause");
return;
}
int load(struct Student stu_save[])
{
FILE *fp;
int i,n;
char filename[20];
printf("請輸入要載入的文件名: ");
//getchar();
scanf("%s",filename);
// gets(filename);
if(strchr(filename,'.')==NULL)
strcat(filename,".dat");
if((fp=fopen(filename,"rb"))==NULL)
{
printf("Cannot open this file\n");
system("pause");
return 0;
}
fread(&n,sizeof(int),1,fp);
for(i=0;i<n;i++)
fread(&stu_save[i],sizeof(struct Student),1,fp);
fclose(fp);
system("cls");
printf("文件載入成功!數據如下");
output(stu_save,n);
return n;
}
void output(struct Student stu_save[],int n)
{
int i,j;
// system("cls");
printf("\n學號\t姓名\t性別\t年齡\t成績一\t成績二\t成績三\t總分\t平均分\n");
for(i=0;i<n;i++)
{
printf("%s\t",stu_save[i].num);
printf("%s\t",stu_save[i].name);
printf("%c\t",stu_save[i].sex);
printf("%d\t",stu_save[i].age);
for(j=0;j<3;j++)
printf("%g\t",stu_save[i].score[j]);
printf("%g\t",stu_save[i].tolscore);
printf("%.2f",stu_save[i].ave);
putchar(10);
}
system("pause");
return;
}
int insert(struct Student stu_save[],int n)
{
int i,j,num=0;
float sum=0;
struct Student s;
char flag;
if(n>200)
{
printf("空間已滿,無法插入!\n");
return 0;
}
// load(stu_save,n-1);
do{
printf("\n請依次輸入學號、姓名、性別、年齡及三門課成績\n");
scanf("%s",s.num);
scanf("%s",s.name);
scanf(" %c",&s.sex); //%c前的空格用於接收上一個字元串後的空格、回車、製表符,etc
scanf("%d",&s.age);
for(j=0;j<3;j++)
scanf("%f",&s.score[j]);
sum=0;
for(j=0;j<3;j++)
sum+=s.score[j];
s.tolscore=sum;
s.ave=sum/3;
num++;
for(i=n+num-1;strcmp(stu_save[i-1].num,s.num)>0&&i>0;i--)
stu_save[i]=stu_save[i-1];
stu_save[i]=s;
printf("插入成功!");
fflush(stdin);
do
{
printf("繼續插入?(y/n)");
flag=getch();
}while(flag!='y'&&flag!='n');
}while(flag=='y');
system("pause");
//save(stu_save,n);
return num;
}
void sort(struct Student stu_save[],int n)
{
int a,i,j;
struct Student t;
system("cls");
printf("\n1-按序號排序\n2-按成績排序\n請選擇:");
scanf("%d",&a);
while(a!=1&&a!=2)
{
printf("輸入有誤,請重新輸入!\n");
scanf("%d",&a);
}
//load(stu_save,n);
if(a==1)
{
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
{
if(strcmp(stu_save[j].num,stu_save[j+1].num)>0)
{
t=stu_save[j];
stu_save[j]=stu_save[j+1];
stu_save[j+1]=t;
}
}
}
else
{
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
{
if(stu_save[j].ave<stu_save[j+1].ave)
{
t=stu_save[j];
stu_save[j]=stu_save[j+1];
stu_save[j+1]=t;
}
}
}
// save(stu_save,n);
printf("排序成功!\n");
output(stu_save,n);
return;
}
void find(struct Student stu_save[],int n)
{
char ch;
do{
int i,j,w=1;
char search[20];
//load(stu_save,n);
printf("請輸入學生的學號或姓名");
scanf("%s",search);
for(i=0;i<n;i++)
{
if(strcmp(stu_save[i].num,search)==0||strcmp(stu_save[i].name,search)==0)
{
printf("查找成功,該學生的信息為:\n");
printf("%s\t",stu_save[i].num);
printf("%s\t",stu_save[i].name);
printf("%c\t",stu_save[i].sex);
printf("%d\t",stu_save[i].age);
for(j=0;j<3;j++)
printf("%g\t",stu_save[i].score[j]);
printf("%g\t",stu_save[i].tolscore);
printf("%.2f",stu_save[i].ave);
putchar(10);
w=0;
break;
}
}
if(w)
printf("查找失敗\n");
do
{
printf("\n按Y繼續查找,按N返回上級菜單\n");
ch=getch();
}while(ch!='y'&&ch!='n');
if(ch=='n')
return;
}while(ch=='y');
}
int delete_stu(struct Student stu_save[],int n)
{
int i,w=1;
char search[20];
// load(stu_save,n);
printf("\n請輸入要刪除學生的姓名或學號\n");
scanf("%s",search);
for(i=0;i<n;i++)
if(strcmp(stu_save[i].num,search)==0||strcmp(stu_save[i].name,search)==0)
{
w=0;
break;
}
if(w)
{
printf("無此學生!\n");
return 0;
}
for(;i<n-1;i++)
stu_save[i]=stu_save[i+1];
printf("刪除成功!\n");
// save(stu_save,n-1);
return 1;
}
之前隨便寫的 忘了有沒有調試 有問題再私信找我 採納哦~~
③ C語言設計 學生學籍系統
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
intshoudsave=0;/**/
structstudent
{
charnum[10];/*學號*/
charname[20];
charsex[4];
charyuan;
intban;
charneartime[10];/*最近更新時間*/
};
typedefstructnode
{
structstudentdata;
structnode*next;
}Node,*Link;
voidmenu()
{
printf("********************************************************************************");
printf(" 1登記學生資料 2刪除學生資料 ");
printf(" 3查詢學生資料 4修改學生資料 ");
printf(" 5保存學生資料 0退出系統 ");
printf("******************************************************************************** ");
}
voidprintstart()
{
printf("----------------------------------------------------------------------- ");
}
voidWrong()
{
printf(" =====>提示:輸入錯誤! ");
}
voidNofind()
{
printf(" =====>提示:沒有找到該學生! ");
}
voidprintc()/*本函數用於輸出中文*/
{
printf("學號 姓名性別學院班級 ");
}
voidprinte(Node*p)/*本函數用於輸出英文*/
{
printf("%-12s%s %s %c %d ",p->data.num,p->data.name,p->data.sex,p->data.yuan,p->data.ban);
}
Node*Locate(Linkl,charfindmess[],charnameornum[])/*該函數用於定位連表中符合要求的接點,並返回該指針*/
{
Node*r;
if(strcmp(nameornum,"num")==0)/*按學號查詢*/
{
r=l->next;
while(r!=NULL)
{
if(strcmp(r->data.num,findmess)==0)
returnr;
r=r->next;
}
}
elseif(strcmp(nameornum,"name")==0)/*按姓名查詢*/
{
r=l->next;
while(r!=NULL)
{
if(strcmp(r->data.name,findmess)==0)
returnr;
r=r->next;
}
}
return0;
}
voidAdd(Linkl)/*增加學生*/
{
Node*p,*r,*s;
charnum[10];
r=l;
s=l->next;
while(r->next!=NULL)
r=r->next;/*將指針置於最末尾*/
while(1)
{
printf("請你輸入學號(以'0'返回上一級菜單:)");
scanf("%s",num);
if(strcmp(num,"0")==0)
break;
while(s)
{
if(strcmp(s->data.num,num)==0)
{
printf("=====>提示:學號為'%s'的學生已經存在,若要修改請你選擇'4修改'! ",num);
printstart();
printc();
printe(s);
printstart();
printf(" ");
return;
}
s=s->next;
}
p=(Node*)malloc(sizeof(Node));
strcpy(p->data.num,num);
printf("請你輸入姓名:");
scanf("%s",p->data.name);
getchar();
printf("請你輸入性別:");
scanf("%s",p->data.sex);
getchar();
printf("請你輸入學院:");
scanf("%c",&p->data.yuan);
getchar();
printf("請你輸入班級:");
scanf("%d",&p->data.ban);
getchar();
/*信息輸入已經完成*/
p->next=NULL;
r->next=p;
r=p;
shoudsave=1;}
}
voidQur(Linkl)/*查詢學生*/
{
intsel;
charfindmess[20];
Node*p;
if(!l->next)
{
printf(" =====>提示:沒有資料可以查詢! ");
return;
}
printf(" =====>1按學號查找 =====>2按姓名查找 ");
scanf("%d",&sel);
if(sel==1)/*學號*/
{
printf("請你輸入要查找的學號:");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
printf(" 查找結果 ");
printstart();
printc();
printe(p);
printstart();
}
else
Nofind();
}
elseif(sel==2)/*姓名*/
{
printf("請你輸入要查找的姓名:");
scanf("%s",findmess);
p=Locate(l,findmess,"name");
if(p)
{
printf(" 查找結果 ");
printstart();
printc();
printe(p);
printstart();
}
else
Nofind();
}
else
Wrong();
}
voidDel(Linkl)/*刪除*/
{
intsel;
Node*p,*r;
charfindmess[20];
if(!l->next)
{
printf(" =====>提示:沒有資料可以刪除! ");
return;
}
printf(" =====>1按學號刪除 =====>2按姓名刪除 ");
scanf("%d",&sel);
if(sel==1)
{
printf("請你輸入要刪除的學號:");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
r=l;
while(r->next!=p)
r=r->next;
r->next=p->next;
free(p);
printf(" =====>提示:該學生已經成功刪除! ");
shoudsave=1;
}
else
Nofind();
}
elseif(sel==2)
{
printf("請你輸入要刪除的姓名:");
scanf("%s",findmess);
p=Locate(l,findmess,"name");
if(p)
{
r=l;
while(r->next!=p)
r=r->next;
r->next=p->next;
free(p);
printf(" =====>提示:該學生已經成功刪除! ");
shoudsave=1;
}
else
Nofind();
}
else
Wrong();
}
voidModify(Linkl)
{
Node*p;
charfindmess[20];
if(!l->next)
{
printf(" =====>提示:沒有資料可以修改! ");
return;
}
printf("請你輸入要修改的學生學號:");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
printf("請你輸入新學號(原來是%s):",p->data.num);
scanf("%s",p->data.num);
printf("請你輸入新姓名(原來是%s):",p->data.name);
scanf("%s",p->data.name);
getchar();
printf("請你輸入新性別(原來是%s):",p->data.sex);
scanf("%s",p->data.sex);
printf("請你輸入新的學院:",p->data.yuan);
scanf("%c",&p->data.yuan);
getchar();
printf("請你輸入新的班級(原來是%d):",p->data.ban);
scanf("%d",&p->data.ban);
getchar();
printf(" =====>提示:資料修改成功! ");
shoudsave=1;
}
else
Nofind();
}
voidSave(Linkl)
{
FILE*fp;
Node*p;
intflag=1,count=0;
fp=fopen("c:\student","wb");
if(fp==NULL)
{
printf(" =====>提示:重新打開文件時發生錯誤! ");
exit(1);
}
p=l->next;
while(p)
{
if(fwrite(p,sizeof(Node),1,fp)==1)
{
p=p->next;
count++;
}
else
{
flag=0;
break;
}
}
if(flag)
{
printf(" =====>提示:文件保存成功.(有%d條記錄已經保存.) ",count);
shoudsave=0;
}
fclose(fp);
}
voidmain()
{
Linkl;/*連表*/
FILE*fp;/*文件指針*/
intsel;
charch;
charjian;
intcount=0;
Node*p,*r;
printf(" 學生成績管理系統 -------建築電氣及智能化0801 ");
l=(Node*)malloc(sizeof(Node));
l->next=NULL;
r=l;
fp=fopen("C:\student","rb");
if(fp==NULL)
{
printf(" =====>提示:文件還不存在,是否創建?(y/n) ");
scanf("%c",&jian);
if(jian=='y'||jian=='Y')
fp=fopen("C:\student","wb");
else
exit(0);
}
printf(" =====>提示:文件已經打開,正在導入記錄...... ");
while(!feof(fp))
{
p=(Node*)malloc(sizeof(Node));
if(fread(p,sizeof(Node),1,fp))/*將文件的內容放入接點中*/
{
p->next=NULL;
r->next=p;
r=p;/*將該接點掛入連中*/
count++;
}
}
fclose(fp);/*關閉文件*/
printf(" =====>提示:記錄導入完畢,共導入%d條記錄. ",count);
while(1)
{
menu();
printf("請你選擇操作:");
scanf("%d",&sel);
if(sel==0)
{
if(shoudsave==1)
{getchar();
printf(" =====>提示:資料已經改動,是否將改動保存到文件中(y/n)? ");
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
Save(l);
}
printf(" =====>提示:你已經退出系統,再見! ");
break;
}
switch(sel)
{
case1:Add(l);break;/*增加學生*/
case2:Del(l);break;/*刪除學生*/
case3:Qur(l);break;/*查詢學生*/
case4:Modify(l);break;/*修改學生*/
case5:Save(l);break;/*保存學生*/
case9:printf(" ==========幫助信息========== ");break;
default:Wrong();getchar();break;
}
}
}
④ C語言課程設計:學生學籍管理系統。有誰有代碼給我做個參考嗎謝謝了,C語言和C++的都可以。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct stud //學生信息結構
{
long num;
char name[20];
float score;
}Stud;
typedef struct node
{
Stud student;
struct node *next;
}Node;
Node *head=NULL;
void read(void);
void inser(long b);
void print();
void find(long b);
void searchname(char *s);
Node * del(long n);
void sort(int flag);
void menu();
void main()
{
char choose;
int flag=1;
while (flag)
{
menu(); //調用功能菜單函數,顯示菜單項。
printf(" 請選擇:");
choose=getchar();
switch(choose)
{ 1
case '1': read(); //調用建立鏈表的函數;輸出鏈表信息;
print();
printf("\nPress any key Continue ");
//getchar();
getchar();
break;
case '2': //調用按學號查找學生信息的函數;並輸出查找結果信息;
long c;
printf("input the number you want to find:");
scanf("%ld",&c);
find(c);
printf("\nPress any key Continue.");
getchar();
break;
case '3':
//調用按姓名查找學生信息的函數;並輸出查找結果信息;
char s[20];
printf("input the name you want to find:");
scanf("%s",s);
searchname(s);
printf("\n Press any key Continue.");
getchar();
getchar();
break;
case '4':
//調用根據學號刪除某個學生信息的函數;並輸出刪除後的鏈表信息;
Node *h;
long n;
printf("input the number you want to delete:");
scanf("%ld",&n);
h=del(n);
if(h==NULL) printf("No find the student \n");
else print();
printf("\n Press any key Continue.");
getchar();
getchar();
break;
case '5':
//調用插入新的學生信息的函數;並輸出插入後的鏈表信息;
long a;
printf("input the number for the new:\n");
scanf("%ld",&a);
inser(a); 2
print();
printf("\n Press any key Continue.");
getchar();
getchar();
break;
case '6':
//調用按分數降序排序輸出的函數;並輸出排序後的鏈表信息;
sort(1);
print();
sort(0);
printf("\nPress any key Continue.");
getchar();
getchar();
break;
case '0':
//結束程序運行!
flag=0;
printf("\n *** The End! ***\n");
break;
default: printf("\n Wrong Selection !(選擇錯誤,重選)\n");
getchar();
}
}
}
void menu() //綜合作業功能菜單
{
printf(" \n 學 生 信 息 管 理 系 統\n");
printf(" \n 菜 單\n\n");
printf(" \n 1. 建 立 鏈 表 並 顯 示 \n");
printf(" \n 2. 查 找 某 學 號 的 學 生 信 息 \n");
printf(" \n 3. 查 找 某 姓 名 的 學 生 信 息 \n");
printf(" \n 4. 刪 除 某 個 學 號 的 學 生\n");
printf(" \n 5. 插 入 新 的 學 生 信 息 \n");
printf(" \n 6. 按 分 數 降 序 排 序 輸 出 \n");
printf(" \n 0. 退 出\n\n");
}
void read(void)
{
long a;
printf("input the number:");
scanf("%ld",&a);
while(a>0){ 3
inser(a);
printf("input the number:");
scanf("%ld",&a);
}
}
void inser(long b)
{
Node *last,*current,*p;
current=head;
while(current!=NULL&&b>current->student.num){
last=current;
current=current->next;
}
if(current==NULL||b<current->student.num){
printf("input the name,score:");
p=(Node *)malloc(sizeof(Node));
p->student.num=b;
scanf("%s%f",p->student.name,&p->student.score);
p->next=NULL;
if(current==head){
p->next=head;
head=p;
}
else{
p->next=current;
last->next=p;
}
}
else if(b==current->student.num)
printf("error input a different number:");
}
void print()
{
Node *p=head;
printf("學號 姓名 成績:\n");
while(p!=NULL){
printf("%ld %s %f\n",p->student.num,p->student.name,p->student.score);
p=p->next;
} 4
printf("\n");
}
void find(long b)
{
Node *p=head;
while(p!=NULL&&b!=p->student.num)
p=p->next;
if(!p) printf("No found\n");
else {
printf("學號 姓名 成績\n");
printf("%ld %s %f\n",p->student.num,p->student.name,p->student.score);
}
}
void searchname(char *s)
{
Node *p=head;
int flag=0;
printf("學號 姓名 成績:\n");
while(p!=NULL)
{
if(strcmp(p->student.name,s)==0)
{
printf("%ld %s %f\n",p->student.num,p->student.name,p->student.score);
flag=1;
p=p->next;
continue;
}
else p=p->next;
}
if(!flag) printf("No find");
}
Node * del(long n)
{
Node *p=head,*last;
while(p->student.num!=n){
last=p;
p=p->next;
}
if(p==NULL) return p;
else if(p==head) head=p->next;
else last->next=p->next; 5
return head;
}
void sort(int flag)
{
/*flag==1 按分數排序 else 按學號排序*/
Node *p1,*p2,*k;
float t1;
long t2;
char s[20];
for(p1=head;p1->next;p1=p1->next)
{
k=p1;
for(p2=p1->next;p2;p2=p2->next)
if(flag==1&&k->student.score<p2->student.score||!flag&&k->student.num>p2->student.num)
k=p2;
if(k!=p1){
t1=p1->student.score;
p1->student.score=k->student.score;
k->student.score=t1;
t2=p1->student.num;
p1->student.num=k->student.num;
k->student.num=t2;
strcpy(s,p1->student.name);
strcpy(p1->student.name,k->student.name);
strcpy(k->student.name,s);
}
}
}
給你看看
⑤ 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<fstream>
#include<iomanip>
using namespace std;
class student
{
protected:
int number;
char name[20];
char sex[6];
char place[20];
char nation[6];
char birth[20];
char party[10];
char id[20];
double score[3];
public:
student *next;
student(){ }
~student(){ }
char* getname(){ return name; }
int getnumber(){ return number;}
double getscore(int i) { return score[3];}
float getg(){ return (score[0]+score[1]+score[2]); }
void input()
{
int e=1;
cout<<"\t\t\t按提示輸入:"<<endl;
cout<<"\t\t輸入編號: ";
cin>>number;
cout<<"\t\t輸入姓名: ";
cin>>name;
do
{
cout<<"\t\t輸入性別: ";
cin>>sex;
if(strcmp(sex,"男")==0 || strcmp(sex,"女")==0)
{
cout<<"\t\t輸入籍貫: ";
cin>>place;
cout<<"\t\t輸入民族: ";
cin>>nation;
cout<<"\t\t輸入生日: ";
cin>>birth;
cout<<"\t\t輸入政治面貌: ";
cin>>party;
cout<<"\t\t輸入身份證號: ";
cin>>id;
cout<<"\t\t輸入數學分數: ";
cin>>score[0];
cout<<"\t\t輸入英語分數: ";
cin>>score[1];
cout<<"\t\t輸入計算機分數: ";
cin>>score[2];
e=0;
}
else
{
cout<<"\t\t\t無此類型性別!重新輸入!"<<endl;
e=1;
}
}while(e);
return ;
}
void input(ifstream & is)
{
is>>number>>name>>sex>>place>>nation>>birth>>party>>id
>>score[0]>>score[1]>>score[2];
is.get();
}
void output()
{
cout<<"學生基本信息如下:"<<endl;
cout<<"編號:"<<number
<<" 姓名:"<<name
<<" 性別:"<<sex
<<" 籍貫:"<<place
<<" 民族:"<<nation
<<" 生日:"<<birth
<<" 政治面貌:"<<party<<endl
<<"身份證號:"<<id
<<" 數學:"<<score[0]
<<" 英語:"<<score[1]
<<" 計算機:"<<score[2]
<<" 總分:"<<getg()<<endl<<endl;
}
void output(ofstream & os)
{
os<<setw(6)<<number
<<setw(15)<<name
<<setw(6)<<sex
<<setw(20)<<place
<<setw(6)<<nation
<<setw(20)<<birth
<<setw(20)<<party
<<setw(20)<<id
<<setw(6)<<score[0]
<<setw(6)<<score[1]
<<setw(6)<<score[2]<<endl;
}
};
class school
{
public:
school(){ head=new student; head->next=NULL; key=0; }
~school(){ delete head; }
void input();
void mend();
void del();
int find(student **p,int num,char *pn="^");
void found();
void show();
void count();
void save();
void begin();
void clear();
char mainmenu();
int getkey(){ return key;}
void setkey(int k){ key=k; }
private:
student *head;
int key;
};
//錄入函數
void school::input()
{
student *p,*p2=NULL;
p=head;
int n;
while(p->next)
p=p->next;
while(n)
{
p2=new student;
p2->input();
p->next=p2;
p2->next=NULL;
p=p->next;
school::setkey(1);
cout<<"\t\t\t按1繼續,按0返回 : ";
cin>>n;
}
}
//子查找函數
int school::find(student **p1,int num,char *pn)
{
student *p;
p=head;
while(p->next)
{
(*p1)=p;
if( (p->next)->getnumber()==num||!strcmp( (p->next)->getname(),pn ) )
return 1;
p=p->next;
}
return 0;
}
//查找函數
void school::found()
{
student *p;
int num=-1,n=9;
char name[20]="^";
do
{
cout<<"\t\t1:按編號查找,2:按姓名查找: ";
cin>>n;
}while(n<1||n>2);
if(n==1)
{
cout<<"\t\t\t輸入編號: ";
cin>>num;
}
if(n==2)
{
cout<<"\t\t\t輸入姓名: ";
cin>>name;
}
if(!find(&p,num,name) )
{
cout<<"\t\t找不到你要查找的內容!"<<endl;
return;
}
(p->next)->output();
}
//刪除函數
void school::del()
{
student *p,*p2;
int num;
cout<<"\t\t\t輸入編號: ";
cin>>num;
if( !find(&p,num,"^") )
{
cout<<"\t\t找不到你要刪除的內容!"<<endl;
return;
}
(p->next)->output();
p2=p->next;
p->next=p2->next;
delete p2;
school::setkey(1);
}
//顯示函數
void school::show()
{
student *p;
p=head;
while(p->next)
{
(p->next)->output();
p=p->next;
}
}
//修改函數
void school::mend()
{
student *p;
int num=-1,n;
char name[20]="^";
do
{
cout<<"\t\t1:按編號修改,2:按姓名修改: ";
cin>>n;
}while(n<1||n>2);
if(n==1)
{
cout<<"\t\t\t輸入編號: ";
cin>>num;
}
if(n==2)
{
cout<<"\t\t\t輸入姓名: ";
cin>>name;
}
if( !find(&p,num,name) )
{
cout<<"\t\t找不到你要修改的內容!"<<endl;
return;
}
(p->next)->output();
(p->next)->input();
school::setkey(1);
}
//保存函數
void school::save()
{
student *p;
p=head;
ofstream os("student.txt",ios::out);
if (school::getkey()==1)
{
while(p->next)
{
(p->next)->output(os);
p=p->next;
}
}
cout<<"\t\t\t文件已保存! "<<endl;
school::setkey(0);
}
//初始化函數
void school::begin()
{
student *p,*p2;
p=head;
clear();
long t;
ifstream is("student.txt",ios::in);
if(!is)
{
ofstream os("student.txt",ios::out);
os.close();
return ;
}
int num=-1;
while(1)
{
num=-1;
t=is.tellg();
is>>num;
is.seekg(t);
if(num<0)
{
is.close();
return;
}
p2=new student;
p2->input(is);
p->next=p2;
p2->next=NULL;
p=p->next;
}
}
//清空函數
void school::clear()
{
student *p,*p2;
p=head->next;
while( p )
{
p2=p;
p=p->next;
delete p2;
}
}
//統計函數
void school::count()
{
student *p;
p=head;
int n=0;
double g[3]={0,0,0};
float j[3]={0,0,0};
while(p->next)
{
p=p->next;
n++;
for(int i=0;i<3;i++)
{
g[++i]=g[i]+( p->getscore(i) );
(p->getscore(i) )>=60? j[i++] : 0 ;
}
}
cout<<"\t\t\b\b\b\b數學總分:"<<g[0]<<" 平均分:"<<g[0]/n
<<" 及格率:"<<j[0]/n<<endl<<"\t\t\b\b\b\b英語總分:"<<g[1]
<<" 平均分:"<<g[1]/n<<" 及格率:"<<j[1]/n<<endl
<<"\t\t\b\b\b\b計算機總分: "<<g[2]<<" 平均分: "<<g[2]/n
<<" 及格率:"<<j[2]/n<<endl;
}
//主選菜單函數
char school::mainmenu()
{
char n[6];
cout<<"\n\n ☆☆☆☆歡迎進入高校學籍管理系統☆☆☆☆"<<endl<<endl
<<" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl
<<" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl
<<" * * 1: 錄入學生信息 * *"<<endl
<<" * * 2: 顯示學生信息 * *"<<endl
<<" * * 3: 查找學生信息 * *"<<endl
<<" * * 4: 刪除學生信息 * *"<<endl
<<" * * 5: 修改學生信息 * *"<<endl
<<" * * 6: 統計學生成績 * *"<<endl
<<" * * 7: 保存學生信息 * *"<<endl
<<" * * 0: 退出系統 * *"<<endl
<<" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl
<<" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl
<<" 請選擇:";
cin>>n;
return n[0];
}
//主函數
void main()
{
school pp;
int k=1;
char n;
pp.begin();
while(k==1)
{
n=pp.mainmenu();
switch(n)
{
case '1':pp.input(); break;
case '2':pp.show(); break;
case '3':pp.found(); break;
case '4':pp.del(); break;
case '5':pp.mend(); break;
case '6':pp.count(); break;
case '7':pp.save(); break;
case '0':
if(pp.getkey()==1)
{
cout<<"\t\t\t是否保存? 1 : 保存 0:不保存 : ";
cin>>k;
if(k==1)
pp.save();
}
pp.clear();
k=0;
break;
}
}
}
⑦ c語言程序設計——學籍管理
"學生學籍管理"的C程序
#include<stdlib.h>
#include<stdio.h>
#include<malloc.h>
struct list{
int num;
char name[256];
int china;
int english;
int math;
struct list *next;
};
typedef struct list node;
typedef node *link;
void printf_list(link head)
{
link pointer;
pointer=head;
while(pointer!=NULL)
{
printf("number:%d\n",pointer->num);
printf("name:%s\n",pointer->name);
printf("china:%d\n",pointer->china);
printf("english:%d\n",pointer->english);
printf("math:%d\n",pointer->math);
pointer=pointer->next;
}
}
link creat_list(link head)
{
int cnum;
char cname[256];
int cchina;
int cenglish;
int cmath;
link pointer, newd;
int i;
head=(link)malloc(sizeof(node));
if(head==NULL)
{ printf("memory allocate failure!!\n");
exit(0);}
else{
printf("please input number:");
scanf("%d",&cnum);
printf("please input name:");
scanf("%s",&cname);
printf("please input china:");
scanf("%d",&cchina);
printf("please input english:");
scanf("%d",&cenglish);
printf("please input math:");
scanf("%d",&cmath);
head->num=cnum;
for(i=0;i<256;i++)
{
head->name[i]=cname[i];
}
head->china=cchina;
head->english=cenglish;
head->math=cmath;
head->next=NULL;
pointer=head;
while(1)
{
newd=(link)malloc(sizeof(node));
if(newd==NULL){
printf("memory allocate failure!!\n");
exit(0);}
printf("please input number:");
scanf("%d",&cnum);
if(cnum==0){
break; }
printf("please input name:");
scanf("%s",cname);
printf("please input china:");
scanf("%d",&cchina);
printf("please input english:");
scanf("%d",&cenglish);
printf("please input math:");
scanf("%d",&cmath);
newd->num=cnum;
for(i=0;i<256;i++){
newd->name[i]=cname[i];}
newd->china=cchina;
newd->english=cenglish;
newd->math=cmath;
newd->next=NULL;
pointer->next=newd;
pointer=newd;
}
}
return head;
}
void search_chengji(int key1,link head)
{
link pointer;
pointer=head;
while(pointer!=NULL)
{
if(pointer->num==key1)
{
printf("number:%d\n",pointer->num);
printf("name:%s\n",pointer->name);
printf("china:%d\n",pointer->china);
printf("english:%d\n",pointer->english);
printf("math:%d\n",pointer->math);
}
pointer=pointer->next;
}
}
link modify_chengji(link head,int key3)
{
link pointer;
char xname[256];
int xchina;
int xenglish;
int xmath;
int choose,i;
pointer=head;
printf("enter 0 exit modefiy\n");
printf("enter 1 modefiy name\n");
printf("enter 2 modefiy china\n");
printf("enter 3 modefiy english\n");
printf("enter 4 modefiy math\n");
scanf("%d",&choose);
switch(choose)
{
case 1:
printf("please input name:");
scanf("%s",&xname);
break;
case 2:
printf("please input china:");
scanf("%d",&xchina);
break;
case 3:
printf("please input english:");
scanf("%d",&xenglish);
break;
case 4:
printf("please input math:");
scanf("%d",&xmath);
break;
}
while(1){
pointer=pointer->next;
if(pointer->num==key3)
{
if(choose==1)
{ for(i=0;i<256;i++)
{
pointer->name[i]=xname[i];
}
break;
}
else if(choose==2)
{ pointer->china=xchina;
break;}
else if(choose==3)
{ pointer->english=xenglish;
break;
}
else if(choose==4)
{pointer->math=xmath;
break;}
}
}
return head;
}
link delete_chengji(link head,int key2)
{
link pointer;
link back;
pointer=head;
while(1)
{
if(head->num==key2)
{ head=pointer->next;
free(pointer);
break;
}
back=pointer;
pointer=pointer->next;
if(pointer->num==key2)
{
back->next=pointer->next;
free(pointer);
break;}
}
return head;
}
link insert_chengji(link head,link newd,int key3)
{
link pointer;
pointer=head;
while(1)
{
if(pointer==NULL){
newd->next=head;
head=newd;
break;}
if(pointer->num==key3){
newd->next=pointer->next;
pointer->next=newd;
break;}
pointer=pointer->next;
}
return head;
}
void pingjufen(link head)
{
link pointer;
int pchina,ppchina;
int penglish,ppenglish;
int pmath,ppmath;
int count;
pchina=0;
penglish=0;
pmath=0;
count=0;
pointer=head;
while(1)
{
pchina=pchina+pointer->china;
penglish=penglish+pointer->english;
pmath=pmath+pointer->math;
count=++count;
if(pointer->next==NULL)
{
break;
}
pointer=pointer->next;
}
ppchina=pchina/count;
ppenglish=penglish/count;
ppmath=pmath/count;
printf("china ping jun fen:%d\n",ppchina);
printf("english ping jun fen:%d\n",ppenglish);
printf("math ping jun fen:%d\n",ppmath);
}
void main()
{
for(;;)
{
link head;
link newd;
int key;
int keynum;
printf("0>exit the programm.\n");
printf("1>create list.\n");
printf("2>search chengji.\n");
printf("3>modify chengji.\n");
printf("4>delete chengji.\n");
printf("5>add chengji.\n");
printf("6>pingjunfeng.\n");
printf("7>print chengji.\n");
scanf("%d",&key);
switch(key){
case 0:
exit(0);
case 1:
head=creat_list(head);
if(head!=NULL)
{ printf_list(head);}
break;
case 2:
printf("please input 0 Exit.\n");
printf("please input number for search:");
scanf("%d",&keynum);
if(keynum==0){
break; }
search_chengji(keynum,head);
break;
case 3:
printf("please input number for modify:");
scanf("%d",&keynum);
head=modify_chengji(head,keynum);
if(head!=NULL)
{
printf_list(head);
}
break;
case 4:
printf("please input 0 exit\n");
printf("please input number for delete:");
scanf("%d",&keynum);
if(keynum==0){
break; }
head=delete_chengji(head,keynum);
break;
case 5:
if(head!=NULL){
newd=(link)malloc(sizeof(node));
printf("please input number:");
scanf("%d",&newd->num);
if(newd->num==0){
break;}
printf("please input name:");
scanf("%s",&newd->name);
printf("please input china:");
scanf("%d",&newd->china);
printf("please input english:");
scanf("%d",&newd->english);
printf("please input math:");
scanf("%d",&newd->math);
printf("please input the data number for insert:");
scanf("%d",&keynum);
head=insert_chengji(head,newd,keynum);
if(head!=NULL) {
printf_list(head);}
}
break;
case 6:
pingjufen(head);
break;
case 7:
printf_list(head);
break;
}
}
}
⑧ 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("