導航:首頁 > 中小學校 > 中小學校學生成績管理系統v20版

中小學校學生成績管理系統v20版

發布時間:2021-02-12 19:43:28

㈠ c語言程序設計:學生成績管理系統


include "stdio.h" /*I/O函數*/
#include "stdlib.h" /*其它說明*/
#include "string.h" /*字元串函數*/
#include "conio.h" /*屏幕操作函數*/
#include "mem.h" /*內存操作函數*/
#include "ctype.h" /*字元操作函數*/
#include "alloc.h" /*動態地址分配函數*/
struct score
{
int mingci;
char xuehao[8];
char mingzi[20];
float score[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;

void shuru()
{
if((fp=fopen("s_score.txt","ab+"))==NULL)
{
printf("cannot open this file.\n");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("\nPlease shuru xuehao:");
gets(data.xuehao);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please shuru wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please shur huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];
fwrite(&data,sizeof(data),1,fp);
printf("another?y/n");
ch=getch();
if(ch=='n'||ch=='N')
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen("s_score.txt","rb+"))==NULL)
{
printf("Cannot reading this file.\n");
exit(0);
}
for(i=0;i<=1000;i++)
{
if((fread(&info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf("\nxuehao mingzi yuwen shuxue yingyu wuli huauxue zhongfen\n");
for(j=0,k=1;j<i;j++,k++)
{
info[j].mingci=k;
printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n",info[j].xuehao,info[j].mingzi,info[j].score[0],info[j].score[1],info[j].score[2],info[j].score[3],info[j].score[4],
info[j].score[5]);
}
getch();
fclose(fp);
}

void xiugai()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xiugai xuehao:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("xuehao:%s\nmingzi:%s\n",data.xuehao,data.mingzi);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please input wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please input huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];

} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}

fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_score.txt","rb"))==NULL)
{
printf("\nCannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xuehao chakan:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf("xuehao:%s mingzi:%s\nyuwen:%f\n shuxue:%f\n yingyu:%f\n wuli:%f\n huaxue:%f\n ",data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("\nopen score.txt was failed!");
getch();
exit(0);
}
printf("\nPlease input ID which you want to del:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{

printf("Anykey will delet it.\n");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_score.txt");
rename("temp.txt","s_score.txt");
printf("Data delet was succesful!\n");
printf("Anykey will return to main.");
getch();
}
main()
{
while(1)
{
clrscr(); /*清屏幕*/
gotoxy(1,1); /*移動游標*/
textcolor(YELLOW); /*設置文本顯示顏色為黃色*/
textbackground(BLUE); /*設置背景顏色為藍色*/
window(1,1,99,99); /* 製作顯示菜單的窗口,大小根據菜單條數設計*/
clrscr();
printf("*************welcome to use student manage******************\n");
printf("*************************menu********************************\n");
printf("* ========================================================= * \n");
printf("* 1>shuru 2>xiugai * \n");
printf("* 3>shanchu 4>chazhao * \n");
printf("* 5>xianshi 6>exit * \n");
printf("* * \n");
printf("* --------------------------------------------------------- * \n");
printf(" Please input which you want(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0);
default: continue;
}
}
}
在tc中運行

㈡ 跪求mfc的學生成績管理系統,簡單的增刪改查就行,資料庫是ACCESS,小弟就20財富,全給大家了.

給你傳了一個壓縮的,裡面有兩個系統都是,有一個csdn程序員網站 要注冊 那裡有很多!以後可以自己找了!

㈢ C程序班級成績管理系統

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define t 100
void fun(struct student *s);
void fun1(struct student *s);
void fun2(struct student *s);
void fun3(struct student *s);
void fun4(struct student *s);
void fun5(struct student *s);
void fun6(struct student *s);
struct student
{
char no[20];
char name[20];
char spec[20];
int grade;
char sex[20];
};
void main()
{
struct student s[t]=,
,
,
,
};

fun(s);
}
void fun(struct student *s)
{
int n;
printf("\n\n\t\t學生檔案管理系統");
printf("\n\n\t----------------------------------------");
printf("\n\n\t\t1:錄入學生信息系統");
printf("\n\n\t\t2:修改學生信息系統");
printf("\n\n\t\t3:刪除學生信息系統");
printf("\n\n\t\t4:查詢學生信息系統");
printf("\n\n\t\t5:輸出學生信息系統");
printf("\n\n\t\t6:退出系統");
printf("\n\n\t----------------------------------------");
printf("\n\n請選擇你要的服務(按數字1~6進入):");
scanf("%d",&n);
system("cls");
if(n==1)
{
printf("\n\n\t\t歡迎進入錄入學生系統");
fun1(s);
}
else if(n==2)
{
printf("\n\n\t\t歡迎進入修改學生系統");
fun5(s);
}
else if(n==3)
{
printf("\n\n\t\t歡迎進入刪除學生系統");
fun6(s);
}
else if(n==4)
{
printf("\n\n\t\t歡迎進入查詢學生系統");
printf("\n\n\t----------------------------------------");
printf("\n\n\t\t1:按學號查詢學生信息系統");
printf("\n\n\t\t2:按班級查詢學生信息系統");
printf("\n\n\t----------------------------------------");
printf("\n\n請選擇你要的服務(按數字1~2進入):");
scanf("%d",&n);
system("cls");
if(n==1)
{
printf("\n\n\t\t1:按學號查詢學生信息系統");
fun2(s);
}
else if(n==2)
{
printf("\n\n\t\t1:按班級查詢學生信息系統");
fun3(s);
}
else
{
printf("\n\n\t\t數據錯誤");
}
}
else if(n==5)
{
printf("\n\n\t\t歡迎進入輸出學生系統");
fun4(s);

} else if(n==6)
{
printf("\n\n\t\t謝謝使用學生管理系統!\n");
printf("\n\n\t\t請雙擊Enter鍵退出系統:");
getchar();
getchar();
exit(0);
}
else
printf("\n\n\t\t數據錯誤");
}
void fun1(struct student *s)
{
int n,i;
char d;
printf("\n\n\t請輸入學生的數量:");
scanf("%d",&n);
for(i=5;i<n+5;i++)
{
printf("\n\t\t請輸入學生學號:");
scanf("%s",s[i].no);
printf("\n\t\t請輸入學生姓名:");
scanf("%s",s[i].name);
printf("\n\t\t請輸入學生專業:");
scanf("%s",s[i].spec);
printf("\n\t\t請輸入學生年級:");
scanf("%d",&s[i].grade);
printf("\n\t\t請輸入學生性別:");
scanf("%s",s[i].sex);
getchar('\n');
system("cls");
}
printf("\n\n\t\t學號\t姓名\t專業\t年級\t性別");
printf("\n\t---------------------------------------------------");
for(i=0;i<n+5;i++)
{
printf("\n\n\t\t%-8s%-8s%-8s%-8d%-8s",s[i].no,s[i].name,s[i].spec,s[i].grade,s[i].sex);
}
printf("\n\t---------------------------------------------------\n");
printf("返回首頁(請按任意鍵):");
scanf("%c",&d);
system("cls");
fun(s);
}
void fun2(struct student *s)
{
char a[20],d;
int i;
printf("\n\n\t請輸入要查詢學生的學號(10001~10005):");
scanf("%s",a);
for(i=0;i<5;i++)
{
if(!strcmp(s[i].no,a))
{
printf("\n\t此學生的信息:");
printf("\n\n\t\t學號\t姓名\t專業\t年級\t性別");
printf("\n\t---------------------------------------------------");
printf("\n\n\t\t%-8s%-8s%-8s%-8d%-8s\n",s[i].no,s[i].name,s[i].spec,s[i].grade,s[i].sex);
printf("\n\t---------------------------------------------------");
}

if(i==4&&s[i].no!="10005")
{
printf("\n\t\t查無此人!");

}
}
printf("\n\n返回首頁(請按任意鍵):");
getchar();
scanf("%c",&d);
system("cls");
fun(s);
}
void fun3(struct student *s)
{
int i,a;
char d;
printf("\n\n\t請輸入要查詢學生的班級(12~14):");
scanf("%d",&a);
for(i=0;i<5;i++)
{
if(a==s[i].grade)
{
printf("\n\t此學生的信息:");
printf("\n\n\t\t學號\t姓名\t專業\t年級\t性別");
printf("\n\t---------------------------------------------------");
printf("\n\n\t\t%-8s%-8s%-8s%-8d%-8s\n",s[i].no,s[i].name,s[i].spec,s[i].grade,s[i].sex);
printf("\n\t---------------------------------------------------");
}
if(i==4&&s[i].grade!=a)
{
printf("\n\t\t查無此人!");

}
}
printf("\n\n返回首頁(請按任意鍵):");
getchar();
scanf("%c",&d);
system("cls");
fun(s);
}
void fun4(struct student *s)
{
int i;
char d;
printf("\n\n\t\t學號\t姓名\t專業\t年級\t性別");
printf("\n\t---------------------------------------------------");
for(i=0;i<5;i++)
{
printf("\n\n\t\t%-8s%-8s%-8s%-8d%-8s",s[i].no,s[i].name,s[i].spec,s[i].grade,s[i].sex);
}
printf("\n\t---------------------------------------------------\n");
printf("返回首頁(請按任意鍵):");
scanf("%c",&d);
getchar();
system("cls");
fun(s);
}
void fun5(struct student *s)
{
char a[20],d;
int i;
printf("\n\n\t請輸入要修改學生的姓名:");
scanf("%s",a);
for(i=0;i<5;i++)
{
if(!strcmp(s[i].name,a))
{ printf("\n\t\t請輸入修改學號:");
scanf("%s",s[i].no);
printf("\n\t\t請輸入修改專業:");
scanf("%s",s[i].spec);
printf("\n\t\t請輸入修改年級:");
scanf("%d",&s[i].grade);
printf("\n\t\t請輸入修改性別:");
scanf("%s",s[i].sex);
getchar('\n');
system("cls");
}
}
printf("\n\n\t\t學號\t姓名\t專業\t年級\t性別");
printf("\n\t---------------------------------------------------");
for(i=0;i<5;i++)
{
printf("\n\n\t\t%-8s%-8s%-8s%-8d%-8s",s[i].no,s[i].name,s[i].spec,s[i].grade,s[i].sex);
}
printf("\n\t---------------------------------------------------\n");
printf("返回首頁(請按任意鍵):");
scanf("%c",&d);
system("cls");
fun(s);
}
void fun6(struct student *s)
{
char a[20],d;
int i,k;
printf("\n\n\t請輸入要刪除學生的姓名:");
scanf("%s",a);
for(i=0;i<5;i++)
{
if(!strcmp(s[i].name,a))
{
s[i]=s[i+1];
printf("\n\t此學生的信息:");
printf("\n\n\t\t學號\t姓名\t專業\t年級\t性別");
printf("\n\t---------------------------------------------------");
for(k=0;k<4;k++)
{
printf("\n\n\t\t%-8s%-8s%-8s%-8d%-8s\n",s[k].no,s[k].name,s[k].spec,s[k].grade,s[k].se

㈣ 學生成績管理系統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++編寫簡單的學生成績管理系統!!!~~~

發給你了

㈥ 假設收集到了一個班學生的所有成績信息(不低於20人),要求用C語言編寫一個簡單的成績管理系統

代碼已發,在附件,郵件名「代碼」,附件Untitled2.c

如果有疑問歡迎追問。

代碼如下:

#include<stdio.h>

#include<string.h>

#include<malloc.h>

#include<math.h>

#define min(A,B) (A<B?A:B)

#define max(A,B) (A<B?B:A)

typedef struct Student

{

long long int id;

char name[11];

int score[4];

double avg;

struct Student* next;

} Student;

void print(Student* stu)

{

printf("學號:%10lld 姓名:%10s 成績:語文:%3d 數學:%3d 英語:%3d 計算機:%3d 平均分:%3.2lf ",

stu->id,stu->name,stu->score[0],stu->score[1],stu->score[2],stu->score[3],stu->avg);

}

int main(void)

{

Student* head = 0;


int stucount=0;//數量


while(1)

{

printf("輸入操作號:1:錄入學生 2:瀏覽 3:查詢 4:修改 5:排序 6:統計 ");


int quest;

scanf("%d",&quest);

scanf("%*[^ ]");


if(quest==1)

{

printf("錄入學生: ") ;

while(1)

{

printf("請輸入學生學號(-1退出錄入): ");

long long int id;

scanf("%lld", &id);


if(id==-1)break;


Student* newStudent = (Student*)malloc(sizeof(Student));

newStudent->id=id;


printf("請輸入學生名字: ");

scanf("%10s", newStudent->name);

scanf("%*[^ ]");


printf("請輸入學生語文成績: ");

scanf("%d",&(newStudent->score[0]));


printf("請輸入學生數學成績: ");

scanf("%d",&(newStudent->score[1]));


printf("請輸入學生英語成績: ");

scanf("%d",&(newStudent->score[2]));


printf("請輸入學生計算機成績: ");

scanf("%d",&(newStudent->score[3]));


int sum=0;

for(int i=0; i<4; ++i)sum+=newStudent->score[i];

newStudent->avg = sum/4.0;

printf("學生已錄入!平均分為:%lf ",newStudent->avg);


//插入鏈表首,這樣最新添加的顯示在最上面,容易看見效果

newStudent->next=head;

head=newStudent;


++stucount;

}



}

else if(quest==2)

{

if(head==0)

printf("沒有學生! ");

else

{

printf("開始瀏覽學生: ");

int st=0,en=min(st+10,stucount);

while(1)

{

printf("瀏覽學生:%d個到%d個學生 ",st+1,en);

Student* stu = head;

for(int i=0; i<st; ++i)

{

stu=stu->next;

}

for(int i=st; i<en; ++i)

{

print(stu);

stu=stu->next;

}

printf("輸入操作號:1 向後翻頁;2 向前翻頁;-1 退出 ");

int squest;

scanf("%d",&squest);

scanf("%*[^ ]");

if(squest==1)

{

if(en!=stucount) st=en;

}

else if(squest==2)

{

st=max(0,st-10);

}

else if(squest==-1)break;

en=min(st+10,stucount);

}

}

}

else if(quest==3)

{

printf("開始查詢學生信息: ");


while(1)

{

printf("通過什麼查詢?1:學生id 2:學生名字 3:學生語文成績 4:學生數學成績 5:學生英語成績 6:學生計算機成績 7:平均分 -1 退出 ");

int squery,squery2;

scanf("%d", &squery);

if(squery==-1)break;

Student temp;

Student* newStudent = &temp;

if(squery==1)

{

printf("請輸入學生id: ");

scanf("%lld", &(newStudent->id));

}

else if(squery==2)

{

printf("請輸入學生名字: ");

scanf("%10s", newStudent->name);

scanf("%*[^ ]");

}

else if(squery==3)

{

printf("請輸入學生語文成績: ");

scanf("%d",&(newStudent->score[0]));

}

else if(squery==4)

{


printf("請輸入學生數學成績: ");

scanf("%d",&(newStudent->score[1]));

}

else if(squery==5)

{

printf("請輸入學生英語成績: ");

scanf("%d",&(newStudent->score[2]));

}

else if(squery==6)

{

printf("請輸入學生計算機成績: ");

scanf("%d",&(newStudent->score[3]));

}

else if(squery==7)

{

printf("請輸入學生平均分: ");

scanf("%lf",&(newStudent->avg));

}

if(squery>=3 && squery<=7)

{

printf("顯示比此分數高還是低的學生?1:低 2:高 ");

scanf("%d",&squery2);

}


Student* stu = head;

int flag=0;

while(stu!=0)

{

if(squery==1)

{

if(newStudent->id==stu->id)

{

print(stu);

flag=1;

}

}

else if(squery==2)

{

if(strcmp(newStudent->name,stu->name)==0)

{

print(stu);

flag=1;

}

}

else if(squery==7)

{

if((newStudent->avg!=stu->avg) && ((newStudent->avg>stu->avg) ^ (squery2==2)))

{

print(stu);

flag=1;

}

}

else if(squery>2 && squery<7)

{

if((newStudent->score[squery-3]!=stu->score[squery-3]) && ((newStudent->score[squery-3]>stu->score[squery-3]) ^ (squery2==2)))

{

print(stu);

flag=1;

}

}


stu=stu->next;

}

if(flag==0)

{

printf("沒有查到學生! ");

continue;

}



}

}

else if(quest==4)

{

printf("開始修改學生信息: ");


while(1)

{

printf("請輸入學生學號(-1退出修改): ");

long long int id;

scanf("%lld", &id);


if(id==-1)break;


Student* newStudent = head;

Student* lststu = 0;

while(newStudent!=0 && newStudent->id!=id)

{

lststu=newStudent;

newStudent=newStudent->next;

}

if(newStudent==0)

{

printf("沒有查到學生! ");

continue;

}

printf("請輸入操作號:1:修改學生名字 2:修改學生語文成績 3:修改學生數學成績 4:修改學生英語成績 5:修改學生計算機成績 6:刪除學生 ");


int squery;

scanf("%d", &squery);

if(squery==1)

{

printf("請輸入學生名字: ");

scanf("%10s", newStudent->name);

scanf("%*[^ ]");

}

else if(squery==2)

{


printf("請輸入學生語文成績: ");

scanf("%d",&(newStudent->score[0]));

}

else if(squery==3)

{


printf("請輸入學生數學成績: ");

scanf("%d",&(newStudent->score[1]));

}

else if(squery==4)

{

printf("請輸入學生英語成績: ");

scanf("%d",&(newStudent->score[2]));

}

else if(squery==5)

{

printf("請輸入學生計算機成績: ");

scanf("%d",&(newStudent->score[3]));

}

else if(squery==6)

{

stucount--;

if(lststu!=0)

lststu -> next = newStudent -> next;

else

head = newStudent -> next;

printf("已刪除學生! ");

}

if(squery!=6)

{

int sum=0;

for(int i=0; i<4; ++i)sum+=newStudent->score[i];

newStudent->avg = sum/4.0;

printf("學生已修改!他的平均分為:%lf ",newStudent->avg);

}

}

}

else if(quest==5)

{

if(head==0)

printf("沒有學生! ");

else

{

printf("對學生按什麼排序?:1:學生號 2:名字 3:語文成績 4:數學成績 5:修改學生英語成績 5:計算機成績 6:平均分 ");

int squery;

scanf("%d", &squery);

printf("升序還是降序? 1:升序 2:降序 ");

int squery2;

scanf("%d", &squery2);

int flag=1;

Student* stu = head;

Student* lststu = 0;

while(flag==1)

{

flag=0;

while(stu->next!=0)

{

int swflag=0;

if(squery==0)

{

if((stu->next->id > stu->id) ^ (squery2==1))swflag=1;

}

else if(squery==1)

{

if((strcmp(stu->next->name,stu->name)>0) ^ (squery2==1))swflag=1;

}

else if(squery==6)

{

if((stu->next->avg > stu->avg) ^ (squery2==1))swflag=1;

}

if(swflag==1)

{

flag=1;

if(lststu==0) head=stu->next;

else lststu->next=stu->next;

Student* temp = stu->next->next;

stu->next->next=stu;

stu->next=temp;

}

lststu=stu;

stu=stu->next;

}

}

printf("已排序! ");

}


}

else if(quest==6)

{


double totscore[4]= {0};

double sum=0;

Student* stu=head;

while(stu!=0)

{

for(int i=0; i<4; ++i)

{

totscore[i]+=stu->score[i];

sum+=stu->avg;

}

}

for(int i=0; i<4; ++i) totscore[i]=totscore[i]/4.0;

sum=sum/4.0;

printf("統計:學生人數:%d 語文平均分:%lf 數學平均分:%lf 英語平均分:%lf 計算機平均分:%lf 總平均分:%lf ",stucount,totscore[0],totscore[1],totscore[2],totscore[3],sum);

}

else if(quest==-1)

break;

}

return 0;

}

㈦ 學生成績管理

#include<iostream.h>
#include<string.h>
#include<fstream.h>
class stu
{
char name[20];
double math,chinese,english,average,sum;
public:
stu()
{
}
stu(char n[20],double ma,double chin,double eng)
{
strcpy(name,n);
math=ma;
chinese=chin;
english=eng;
}
double getsum()
{
sum=chinese+english+math;
return sum;
}
double getaver()
{
average=getsum()/3;
return average;
}
friend void main();
};

void main()
{
cout<<"請選擇您需要的操作!"<<endl;
cout<<"操作:"<<endl;
cout<<"(0)數據錄入"<<endl;
cout<<"(1)增加人員"<<endl;
cout<<"(2)刪除人員"<<endl;
cout<<"(3)修改數據"<<endl;
cout<<"查詢:"<<endl;
cout<<"(4)按總成績查詢"<<endl;
cout<<"(5)按姓名查詢"<<endl;
cout<<"(6)輸出所有學生的數據"<<endl;
cout<<"成績名詞"<<endl;
cout<<"(7)按總分查詢排名"<<endl;
cout<<"(8)按語文查詢排名"<<endl;
cout<<"(9)按數學查詢排名"<<endl;
cout<<"(y)按英語查詢排名"<<endl;
cout<<"選擇相關操作請輸入相對的括弧里的阿拉伯數字!"<<endl;
char p;char w;
stu *s[50];
ofstream *file[50];
int i=0;
int j=0;
bool flag2=0;
do
{
cin>>p;
if((p>='0'&&p<='10'))
flag2=1;
else
cout<<"指令錯誤!請重新輸入:"<<endl;
}while(flag2==0);
do{
switch(p)
{
case '0':
{
char c;
char name[20];double math,chinese,english;
do{
cout<<"請輸入姓名"<<endl;
cin>>name;
cout<<"請輸入數學成績:"<<endl;
cin>>math;
cout<<"請輸入語文成績:"<<endl;
cin>>chinese;
cout<<"請輸入外語成績:"<<endl;
cin>>english;
file[j]=new ofstream("d:\\document",ios::ate);
*file[j]<<"姓名"<<name<<"數學成績"<<math<<"語文成績"<<chinese<<"外語成績"<<english<<endl;
j++;
s[i]=new stu(name, math, chinese, english);
i++;
cout<<"數據錄入成功,想繼續錄入嗎(y/n)"<<endl;
cin>>c;
flag2=0;
do
{
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
else
flag2=1;
}while(flag2==0);
}while(c=='y');
break;
}
case '4':
{
double t;char c;
do
{
int flag1=0;
cout<<"請輸入你要查詢學生的總成績"<<endl;
cin>>t;
for(int q=0;q<i;q++)
{
if(s[q]->getsum()==t)
{
flag1=1;
cout<<"您要查詢的學生是:"<<(*s[q]).name<<endl;
}
}
if(flag1==0)
cout<<"對不起!您要查詢的學生不存在!"<<endl;
cout<<"您想繼續查詢嗎?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}

case '5':
{
char n[20];int j=0;char c;
do{
int flag=0;
cout<<"請輸入你要查詢的學生姓名"<<endl;
cin>>n;
for(int j=0;j<i;j++)
{
if(strcmp(n,(*s[j]).name)==0)
{
flag=1;
cout<<"您要查詢的學生是:"<<(*s[j]).name<<endl;
cout<<(*s[j]).name<<"的總成績成績是"<<(*s[j]).getsum()<<endl<<"平均成績是:"<<(*s[j]).getaver()<<endl;
}
}
if(flag==0)
cout<<"對不起!您要查詢的學生不存在!"<<endl;
cout<<"您想繼續查詢嗎?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '1':
{
char name[20];double math,chinese,english;
char c;
do
{
cout<<"請輸入您要增加的學生的姓名:"<<endl;
cin>>name;
cout<<"請輸入數學成績:"<<endl;
cin>>math;
cout<<"請輸入語文成績:"<<endl;
cin>>chinese;
cout<<"請輸入外語成績:"<<endl;
cin>>english;
file[j]=new ofstream("d:\\document",ios::ate);
*file[j]<<"姓名"<<name<<"數學成績"<<math<<"語文成績"<<chinese<<"外語成績"<<english<<endl;
j++;
s[i]=new stu(name, math, chinese, english);
i++;
cout<<"數據錄入成功,想繼續錄入嗎(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '2':
{
char name[20];bool flag3=0;char c;
do{
cout<<"請輸入您要刪除的學生姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
flag3=1;
i--;
do{
s[h]=s[h+1];
h++;
}while(h<=i);
}
}
if(flag3==0)
cout<<"您要求刪除的對象本來就不存在!請檢查輸入的正確性!";
cout<<"要繼續刪除嗎?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '3':
{
char name[20];double mat,chin,eng;flag2=0;
char c;
do
{
cout<<"請輸入您要修改的學生的姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
flag2=1;
cout<<"請輸入新的數學成績:"<<endl;
cin>>mat;
cout<<"請輸入新的語文成績:"<<endl;
cin>>chin;
cout<<"請輸入新的外語成績:"<<endl;
cin>>eng;
s[h]->chinese=chin;
s[h]->math=mat;
s[h]->english=eng;
cout<<"數據修改成功!";
}
}
if(flag2==0)
{
cout<<"您要修改的學生本來就不存在!請檢查重新輸入!"<<endl;
}
cout<<"想繼續修改嗎(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}

case '6':
{
cout<<"本系統所有學生數據如下:"<<endl;
if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!"<<endl;
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"語文:"<<" "<<s[k]->chinese<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english<<"總分:"<<" "<<(*s[k]).getsum()
<<"平均分:"<<" "<<(*s[k]).getaver()<<endl;
}
break;
}
case '7':
{
int t;stu b;

cout<<"本系統所以學生排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->getsum())<(s[y]->getsum()))
t=y;
if(t!=x)
{
b=*s[x];
*s[x]=*s[t];
*s[t]=b;
}
}
}
if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"語文:"<<" "<<s[k]->chinese<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
break;
}
case '8':
{
int t;stu b;

cout<<"本系統所以學生語文排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->chinese)<(s[y]->chinese))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"語文:"<<" "<<s[k]->chinese<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
break;
}
case '9':
{
int t;stu b;

cout<<"本系統所以學生數學排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->math)<(s[y]->math))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"語文:"<<" "<<s[k]->chinese<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
break;
}
case 'y':
{
int t;stu b;

cout<<"本系統所以學生英語排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->english)<(s[y]->english))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"語文:"<<" "<<s[k]->chinese<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
}
break;
}

cout<<"您想繼續進行其他操作嗎?(y/n)"<<endl;
bool flag4=0;
do
{
cin>>w;
if(w!='y'&&w!='n')
cout<<"指令錯誤!請重新輸入!"<<endl;
else
flag4=1;
}while(flag4==0);
if(w=='y')
cout<<"請輸入操作代碼(0 錄入/4 按總分查詢/5 按姓名查詢/1 增加人員/2 刪除人員/3 修改數據/6 顯示所有成員數據/7 按總分排名/8 按語文排名/9按數學排名/y按英語排名)"<<endl;
cin>>p;
}while(w=='y');
for(int x=0;x<i;x++)
{
delete s[x];
cout<<"delete all members!"<<endl;
}

}

㈧ c++ 學生成績管理系統

這是我剛改過的代碼,還添加了求平均分的功能
#include<iostream.h>
#include<string.h>
#include<fstream.h>
class stu
{
char name[20];
int ba;
double math,number,chinese,english,average,sum;
public:
stu()
{
}
stu(char n[20],int ban,double nu,double ma,double chin,double eng)
{
strcpy(name,n);
ba=ban;
number=nu;
math=ma;
chinese=chin;
english=eng;
}
double getsum()
{
sum=chinese+english+math;
return sum;
}
double getaver()
{
average=getsum()/3;
return average;
}
friend void main();
};

void main()
{
cout<<"(0)數據錄入 (1)增加人員"<<endl;
cout<<"(2)刪除人員 (3)修改數據"<<endl;
cout<<"(4)按學號查詢 (5)按姓名查詢"<<endl;
cout<<"(6)輸出所有學生的數據 (7)按總分查詢排名"<<endl;
cout<<"(8)按語文查詢排名 (9)按數學查詢排名"<<endl;
cout<<"(y)按英語查詢排名 "<<endl;
cout<<"選擇相關操作請輸入相對的括弧里的阿拉伯數字或字母!"<<endl;
char p;char w;
stu *s[50];
ofstream *file[50];
int i=0;
int j=0;
bool flag2=0;
do
{
cin>>p;
if((p>='0'&&p<='9'))
flag2=1;
else
cout<<"指令錯誤!請重新輸入:"<<endl;
}while(flag2==0);
do{
switch(p)
{
case '0':
{
char c;
char name[20];int ba ;double number, math,chinese,english;
do{
cout<<"請輸入姓名"<<endl;
cin>>name;
cout<<"請輸入班級:"<<endl;
cin>>ba;
cout<<"請輸入您要增加的學生的學號:"<<endl;
cin>>number;
cout<<"請輸入數學成績:"<<endl;
cin>>math;
cout<<"請輸入語文成績:"<<endl;
cin>>chinese;
cout<<"請輸入外語成績:"<<endl;
cin>>english;
file[j]=new ofstream("d:\\document",ios::ate);
*file[j]<<"姓名"<<name<<"班級"<<ba<<"學號"<<number<<"數學成績"<<math<<"語文成績"<<chinese<<"外語成績"<<english<<endl;
j++;
s[i]=new stu(name,ba,number, math, chinese, english);
i++;
cout<<"數據錄入成功,想繼續錄入嗎(y/n)"<<endl;
cin>>c;
do
{
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
else
flag2=1;
}while(flag2==0);
}while(c=='y');
break;
}
case '1':
{
char name[20];int ba;double number,math,chinese,english;
char c;
do
{
cout<<"請輸入您要增加的學生的姓名:"<<endl;
cin>>name;
cout<<"請輸入要增加的學生的班級:"<<endl;
cin>>ba;
cout<<"請輸入您要增加的學生的學號:"<<endl;
cin>>number;
cout<<"請輸入數學成績:"<<endl;
cin>>math;
cout<<"請輸入語文成績:"<<endl;
cin>>chinese;
cout<<"請輸入外語成績:"<<endl;
cin>>english;
file[j]=new ofstream("d:\\document",ios::ate);
*file[j]<<"姓名"<<name<<"班級"<<ba<<"學號"<<number<<"數學成績"<<math<<"語文成績"<<chinese<<"外語成績"<<english<<endl;
j++;
s[i]=new stu(name, ba,number,math, chinese, english);
i++;
cout<<"數據錄入成功,想繼續錄入嗎(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '2':
{
char name[20];bool flag3=0;char c;
do{
cout<<"請輸入您要刪除的學生姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
flag3=1;
i--;
do{
s[h]=s[h+1];
h++;
}while(h<=i);
}
}
if(flag3==0)
cout<<"您要求刪除的對象本來就不存在!請檢查輸入的正確性!";
cout<<"要繼續刪除嗎?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '3':
{
char name[20];double mat,chin,eng;flag2=0;
char c;
do
{
cout<<"請輸入您要修改的學生的姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
flag2=1;
cout<<"請輸入新的數學成績:"<<endl;
cin>>mat;
cout<<"請輸入新的語文成績:"<<endl;
cin>>chin;
cout<<"請輸入新的外語成績:"<<endl;
cin>>eng;
s[h]->chinese=chin;
s[h]->math=mat;
s[h]->english=eng;
cout<<"數據修改成功!";
}
}
if(flag2==0)
{
cout<<"您要修改的學生本來就不存在!請檢查重新輸入!"<<endl;
}
cout<<"想繼續修改嗎(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}

case '4':
{
double t;char c;
do
{
int flag1=0;
cout<<"請輸入你要查詢學生的學號"<<endl;
cin>>t;
for(int q=0;q<i;q++)
{
if(s[q]->number==t)
{
flag1=1;
cout<<"您要查詢的學生是:"<<(*s[q]).name
<<"數學成績為:"<<s[q]->math
<<"語文成績為:"<<s[q]->chinese
<<"英語成績為:"<<s[q]->english
<<"總分為:"<<s[q]->getsum()
<<endl;
}
}
if(flag1==0)
cout<<"對不起!您要查詢的學生不存在!"<<endl;
cout<<"您想繼續查詢嗎?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}

case '5':
{
char n[20];int j=0;char c;
do{
int flag=0;
cout<<"請輸入你要查詢的學生姓名"<<endl;
cin>>n;
for(int j=0;j<i;j++)
{
if(strcmp(n,(*s[j]).name)==0)
{
flag=1;
cout<<"您要查詢的學生是:"<<(*s[j]).name
<<endl;
cout<<(*s[j]).name<<"的總成績成績是"<<(*s[j]).getsum()
<<"班級:"<<" "<<s[j]->ba
<<"語文:"<<" "<<s[j]->chinese
<<"數學:"<<" "<<s[j]->math
<<"外語:"<<" "<<s[j]->english
<<"平均成績是:"<<(*s[j]).getaver()
<<endl;
}
}
if(flag==0)
cout<<"對不起!您要查詢的學生不存在!"<<endl;
cout<<"您想繼續查詢嗎?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令錯誤!請重新輸入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}

case '6':
{
cout<<"本系統所有學生數據如下:"<<endl;
if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!"<<endl;
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name
<<"班級"<<s[k]->ba
<<"學號"<<s[k]->number
<<"語文:"<<" "<<s[k]->chinese<<"數學:"
<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english
<<"總分:"<<" "<<(*s[k]).getsum()
<<"平均分:"<<" "<<(*s[k]).getaver()
<<endl;
}
break;
}
case '7':
{
int t;stu b;

cout<<"本系統所有學生總分排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->getsum())<(s[y]->getsum()))
t=y;
if(t!=x)
{
b=*s[x];
*s[x]=*s[t];
*s[t]=b;
}
}
}
if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
double o1,o2;
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name
<<"班級"<<s[k]->ba
<<"學號"<<s[k]->number
<<"語文:"<<" "<<s[k]->chinese
<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english
<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()
<<endl;
o1=s[k]->sum;
o2=s[0]->sum;
}
cout<<"總分最高分"<<o2<<endl
<<"總分最低分"<<o1<<endl
<<endl;
break;
}
case '8':
{
int t;stu b;

cout<<"本系統所有學生語文排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->chinese)<(s[y]->chinese))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
double o1 ,o2;
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name
<<"班級"<<s[k]->ba
<<"學號"<<s[k]->number
<<"語文:"<<" "<<s[k]->chinese
<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english
<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()
<<endl;
o1=s[k]->chinese;
o2=s[0]->chinese;
}
int v1=0,v2=0;double v3;
for(v2=0;v2<=i-1;v2++)
{
if(s[v2]->english>=60)
v1++;
}
v3=(v1*100)/v2;
cout<<"語文最高分"<<o2<<endl
<<"語文最低分"<<o1<<endl
<<"語文及格率"<<v3<<"%"
<<endl;
break;
}
case '9':
{
int t;stu b;

cout<<"本系統所有學生數學排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->math)<(s[y]->math))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
double o1,o2;
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name
<<"班級"<<s[k]->ba
<<"學號"<<s[k]->number
<<"語文:"<<" "<<s[k]->chinese
<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english
<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()
<<endl;
o1=s[k]->math;
o2=s[0]->math;
}
int v1=0,v2=0;double v3;
for(v2=0;v2<=i-1;v2++)
{
if(s[v2]->english>=60)
v1++;
}
v3=(v1*100)/v2;
cout<<"數學最高分"<<o2<<endl
<<"數學最低分"<<o1<<endl
<<"數學及格率"<<v3<<"%"
<<endl;
break;
}
case 'y':
{
int t;stu b;

cout<<"本系統所有學生英語排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->english)<(s[y]->english))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
double o1,o2;
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name
<<"班級"<<s[k]->ba
<<"學號"<<s[k]->number
<< "語文:"<<" "<<s[k]->chinese
<<"數學:"<<" "<<s[k]->math
<<"外語:"<<" "<<s[k]->english
<<"總分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()
<<endl;
o1=s[k]->english;
o2=s[0]->english;
}
int v1=0,v2=0;double v3;
for(v2=0;v2<=i-1;v2++)
{
if(s[v2]->english>=60)
v1++;
}
v3=(v1*100)/v2;
cout<<"英語最高分"<<o2<<endl
<<"英語最低分"<<o1<<endl
<<"英語及格率"<<v3<<"%"
<<endl;
}
break;
}

cout<<"您想繼續進行其他操作嗎?(y/n)"<<endl;
bool flag4=0;
do
{
cin>>w;
if(w!='y'&&w!='n')
cout<<"指令錯誤!請重新輸入!"<<endl;
else
flag4=1;
}while(flag4==0);
if(w=='y')
cout<<" 請輸入操作代碼: "<<endl;
cout<<"0 錄入 1 增加人員 2 刪除人員"<<endl;
cout<<"3 修改數據 4 按學號查詢 5 按姓名查詢"<<endl;
cout<<"6 顯示所有成員數據 7 按總分排名 8 按語文排名"<<endl;
cout<<"9 按數學排名 y按英語排名"<<endl;
cin>>p;
}while(w=='y');
}

㈨ 學生成績管理系統c語言編輯的畢業設計 〔20分〕

#include <stdio.h>
#include <stdlib.h>
#include<string.h>

#define MENU_NUM 7
#define N 3

typedef struct s1
{
char no[11]; /*學號由10個字元組成*/
char name[15]; /*學生姓名*/
float score[N]; /*各門課成績*/
float sum; /*總分*/
float average; /*平均分*/
int order; /*名次*/
struct s1 *next; /*指向後繼結點的指針*/
}STUDENT; /*定義結構體類型*/

STUDENT * head=NULL;
void InputData( STUDENT * ptr );
void PrintMenu( );
int Menu_Select( );
void Init( );
void create( );
void print( ) ;
void Delete( );
void append();
void computer();

main()
{
int key;
while(1) {
key=Menu_Select();
switch(key)
{
case 0: Init();
//初試化鏈表。也就是若鏈表不為空則釋放鏈表中所有數據,將head置為空(NULL)
break;
case 1: create();
//創建鏈表,輸入數據
break;
case 2: Delete();
//刪除一個指定學號的記錄數據
break;
case 3: print();
//列印鏈表中所有數據
break;
case 4: computer();
//計算鏈表中所有人的總分和平均分
break;
case 5: append();
//追加一個數據到鏈表的尾部
break;
case 6: Init();
//釋放鏈表
exit(0);
}
};
}

void PrintMenu( )
{
int i;
char * menu[]={
"0. Init list",
"1. Enter list",
"2. Delete a record from list",
"3. Print list",
"4. Compute the score",
"5. Insert record to list",
"6. Quit"
};

printf("\n\n");
for (i=0;i<MENU_NUM;i++)
printf("%s\n",menu[i]);
printf("\nEnter your choice(0-6):");
}

int Menu_Select( )
{
int key;

PrintMenu( );
scanf("%d",&key);
return key;
}

void Init( ) //初始化單鏈表。也就是釋放鏈表中的所有數據
{
STUDENT *p,*ptr;//定義兩個臨時指針變數p,ptr
p=head;ptr=head;//將兩個臨時變數指向頭指針head ;
while(ptr!=NULL)
{
ptr=ptr->next;//ptr指向下一個結構數據
free(p);//釋放p所指向的結構數據的內存
p=ptr;//將p指向ptr所指向的數據
}
head=NULL;//將head指向NULL
}

void create( ) //創建單鏈表
{
STUDENT *pt, *pth=NULL; //定義兩個指針變數:pt指向即將申請新的數據內存,pth指向當前數據
while(1)
{
pt=(STUDENT *)malloc(sizeof(STUDENT));//讓pt指向新申請的內存空間
InputData(pt);//輸入數據,存放到pt所指向的結構數據。注意讓pt的next指向NULL
if (strcmp(pt->no,"@")==0)
{
free(pt);//釋放pt所指向的內存空間
break;//退出循環
}
else if (head==NULL)
{
pth=pt;
head=pt;//將頭指針head和pth指向pt
}
else
{

pth->next=pt; //將pth的next指向pt;
pth=pt; //將pth指向pt;
}
};
}

void print( ) //列印單鏈表中所有數據
{ int i=0;
STUDENT *p;//第一個指針p
p=head;//將p指向head

printf("\n");
printf("******************************STUDENT******************************\n");
printf("|rec|no | name | sc1| sc2| sc3| sum | ave |order|\n");
printf("|---|----------|----------------|----|----|----|------|-----|-----|\n");

//列印表頭
while (p!=NULL)
{
printf("|%3d|%10s|%-16s|%4.1f|%4.1f|%4.1f|%6.2f|%5.1f|%5d|\n",
++i,p->no,p->name,p->score[0],p->score[1],p->score[2],
p->sum,p->average,p->order); //列印p所指向的結構中的所有數據。注意列印數據間的分隔線
p=p->next;//將p指向p的下一個結構數據
}
printf("********************************END********************************\n");//列印表尾
}

void Delete( ) //刪除一個記錄
{
STUDENT *p,*pth;//定義兩個指針p,pth
char no[11];//定義一個整數no(用來存儲輸入的學號)
printf("intput delete no\n");
scanf("%s",no);//用輸入語句輸入一個學號存儲到no中
p=head;pth=head;//將p和pth都指向頭指針
if (strcmp(p->no,no)==0) //也就是若頭指針指向的數據需要刪除
{
head=head->next;//將head指針指向head的下一個數據;
free(p);//釋放p所指向的數據
}
else
{
p=p->next;//將p指向p的下一個數據
while ( p!=NULL)
{
if (strcmp(p->no,no)==0) //找到了要刪除的數據
{
pth->next=p->next;//將pth的next指向p的next
free(p);//釋放p
break;//退出循環
}
else
{
pth=pth->next;//將pth指向pth的next 或 將pth指向p
p=p->next;//將p指向p的next
}
}
}
}

void append()
{
STUDENT *p,*pth;//定義兩個指針變數p,pth

pth=head;//將pth指向head
while ( pth->next!=NULL)
{
pth=pth->next;//ptr指向ptr的next
}

p=(STUDENT *)malloc(sizeof(STUDENT));//將p指向新申請的內存空間
InputData(p);p->next=NULL;//數據數據存儲到p所指向的內存空間,注意將p的next置為NULL
pth->next=p;//將ptr的next指向p
}
void InputData( STUDENT *ptr )
{ int i;
printf("enter no:");
scanf("%s",ptr->no);
if (strcmp(ptr->no,"@")==0 ) return;

printf("enter name:");
scanf("%s",ptr->name);

for(i=0;i<3;i++)
{
printf("shuru chengji\n");
scanf("%f",&ptr->score[i]);
}

ptr->sum=0;
ptr->average=0;
ptr->order=0;
ptr->next=NULL;
}
void computer()
{
STUDENT *p;
p=head;
for(;p;p=p->next)
{
p->sum=p->score[0]+p->score[1]+p->score[2];
p->average=(p->score[0]+p->score[1]+p->score[2])/3;
}
}

閱讀全文

與中小學校學生成績管理系統v20版相關的資料

熱點內容
小學讀書計劃表格模板 瀏覽:342
小學語文四年級感嘆句 瀏覽:243
天通苑中山實驗小學 瀏覽:596
小學三年級語文補習班內容 瀏覽:921
吉安師范附屬小學作文 瀏覽:396
小學教師備課網站 瀏覽:1
私立美男學院 瀏覽:383
小學六年級上冊語文第六單元試卷涼州島 瀏覽:915
小學1年級手gong大全 瀏覽:459
小學生手抄報的圖片大全圖片大全 瀏覽:68
小學健康知識講座 瀏覽:120
小學畢業季適合發老師的句子 瀏覽:451
汕尾鳳山中心小學校長 瀏覽:606
小學生畢業匯演舞蹈 瀏覽:702
小學生抗擊疫情的表演 瀏覽:107
私立華聯大學本科 瀏覽:61
小學三年級作文我想謝謝你400 瀏覽:855
中小學生睡眠問題 瀏覽:174
小學生公共生活守規則教案 瀏覽:313
淮河私立學校 瀏覽:99