admin 管理员组

文章数量: 887053


2024年2月7日发(作者:织梦内容管理系统包括前端吗)

学生管理系统c语言源代码

学生管理系统 c语言源代码

#include stdio.h

#include dos.h

#include string.h

#include stdlib.h

#include malloc.h

#define SIZE 8

struct student

{

char name;

char num;

int score;

float ave;

struct student *next;

}stu[SIZE],temp,s;

void shuru()

{

int i,j,sum,length,flag=1,a;

FILE *fp;

while(flag==1)

{

printf(“Define a rangeclass number:");

scanf("%d",

printf("Input the total number of the class(a):");

scanf("%d",length);

if(lengtha)

flag=0;

}

for(i=0;ilength;i++)

{

printf("n请输入学生的信息:");

printf("n输入姓名:");

scanf("%s",stu[i].name);

printf("n输入序号.:");

scanf("%s",stu[i].num);

printf("n输入成绩:n");

sum=0;

for(j=0;jj++)

{

printf("score %d:",j+1);

scanf("%d",stu[i].score[j]);

sum+=stu[i].score[j];

}

stu[i].ave=sum/3.0;

}

学生管理系统 c语言源代码

fp=fopen("","w");

for(i=0;ilength;i++)

if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)

printf("File write errorn");

fclose(fp);

fp=fopen("","r");

printf("name NO. score1 score2 score3 sum aven");

for(i=0;ilength;i++)

{

fread(stu[i],sizeof(struct student),1,fp);

printf("%3s%5s%7d%7d%7d%7d%10.2fn",stu[i].name,stu[i].num,stu[i].score,

stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score

,stu[i].ave);

}

}

void chaxun()

{ FILE *fp, *fp1;

char n,name;

int i,j,k,t,m,flag=1;

if((fp=fopen("","r"))==NULL)

{printf("Can not open the file.");

exit(0);

}

printf("noriginal data:n");

k=i;

printf("nPlease select the menu( ):");

scanf("%d",

switch(m)

{case 1:printf("nchaxun number:");

scanf("%s",n);

for(flag=1,i=0;ii++)

{if(strcmp(n,stu[i].num)==0)

{j=i;

flag=0;

break;

}

}

break;

case 2:printf("nchaxun name:");

scanf("%s",name);

for(flag=1,i=0;ii++)

{if(strcmp(name,stu[i].name)==0)

{j=i;flag=0;break;

学生管理系统 c语言源代码

}

}

}

if(!flag)

{printf("nYou can find:n");

fp1=fopen("","w");

printf(" name NO. score1 score2 score3aven");

fwrite(stu[j],sizeof(struct student),1,fp1);

printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j]

.score,

stu[j].score,stu[j].ave);

}

else printf("nNot found!");

fclose(fp);

fclose(fp1);

}

xiugai()

{ int a;

printf("nplease select the menu( 2.__ ):");

scanf("%d",

switch(a)

{

case 1:Insert(); break;

case 2:Delete(); break;

}

}

Insert()

{ FILE *fp;

int i,j,t,n;

printf("nNO.:");

scanf("%s",);

printf("name:");

scanf("%s",);

printf("score1,score2,score3:");

scanf("%d,%d,%d",,,);

=(++)/3.0;

if((fp=fopen("","r"))==NULL)

{printf("Can not open the file.");

exit(0);

}

printf("noriginal data:n");

for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)

{printf("n%-15s%11s",stu[i].name,stu[i].num);

for(j=0;jj++)

学生管理系统 c语言源代码

printf("%7d",stu[i].score[j]);

printf("%10.2f",stu[i].ave);

}

fclose(fp);

n=i;

for(t=0;stu[t].++);

printf("nnow:n");

fp=fopen("","w");

for(i=0;ii++)

{fwrite(stu[i],sizeof(struct student),1,fp);

printf("n%-15s%11s",stu[i].name,stu[i].num);

for(j=0;jj++)

printf("%7d",stu[i].score[j]);

printf("%10.2f",stu[i].ave);

}

fwrite(s,sizeof(struct student),1,fp);

printf("n%-15s%11s%7d%7d%7d%10.2f",,,,,

,);

for(i=t;ii++)

{fwrite(stu[i],sizeof(struct student),1,fp);

printf("n%-15s%11s",stu[i].name,stu[i].num);

for(j=0;jj++)

printf("%7d",stu[i].score[j]);

printf("%10.2f",stu[i].ave);

}

fclose(fp);

}

Delete()

{ FILE *fp;

int i,j,t,n,flag;

char number;

if((fp=fopen("","rb"))==NULL)

{printf("Can not open the file.");

exit(0);

}

printf("noriginal data:");

for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)

{printf("n%-15s%11s",stu[i].name,stu[i].num);

for(j=0;jj++)

printf("%7d",stu[i].score[j]);

printf("%10.2f",stu[i].ave);

}

fclose(fp);

n=i;

学生管理系统 c语言源代码

printf("nInput number deleted:");

scanf("%s",number);

for(flag=1,i=0;flagii++)

{if(strcmp(number,stu[i].num)==0)

{for(t=i;tt++)

{strcpy(stu[t].num,stu[t+1].num);

strcpy(stu[t].name,stu[t+1].name);

for(j=0;jj++)

stu[t].score[j]=stu[t+1].score[j];

stu[t].ave=stu[t+1].ave;

}

n=n-1;

else

printf("n Not found!");

printf("nNow,the content of file:n");

fp=fopen("","wb");

for(i=0;ii++)

fwrite(stu[i],sizeof(struct student),1,fp);

fclose(fp);

fp=fopen("","r");

for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)

printf("%-15s%11s%7d%7d%7d%10.2fn",stu[i].name,stu[i].num,stu[i].score,

stu[i].score,stu[i].score,stu[i].ave);

fclose(fp);

}

paixu()

{

FILE *fp;

int i,j,n;

if((fp=fopen("","r"))==NULL)

{printf("Can not open the file.");

exit(0);

}

printf("nfile'':");

for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)

{printf("n%-15s%11s",stu[i].name,stu[i].num);

for(j=0;jj++)

printf("%7d",stu[i].score[j]);

printf("%10.2f",stu[i].ave);

}

fclose(fp);

n=i;

for(i=0;ii++)

for(j=i+1;jj++)

学生管理系统 c语言源代码

if(stu[i].avestu[j].ave)

{temp=stu[i];

stu[i]=stu[j];

stu[j]=temp;

}

printf("nnow:");

fp=fopen("","w");

for(i=0;ii++)

{fwrite(stu[i],sizeof(struct student),1,fp);

printf("n%-15s%11s",stu[i].name,stu[i].num);

tongji()

{ FILE *fp;

int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0;

int a10=0; float t;

if((fp=fopen("","r"))==NULL)

{printf("Can not open the file.");

exit(0);

}

printf("nfile'':");

for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)

{printf("n%-15s%11s",stu[i].name,stu[i].num);

for(j=0;jj++)

printf("%7d",stu[i].score[j]);

printf("%10.2f",stu[i].ave);

}

fclose(fp);

k=i;

for(i=0;ii++)

{labe1=0;

if(stu[i].ave60)

{labe1++;

t=labe1/(float)k*100;

}

}

printf("nbujigelv:");

printf("%f%",t);

printf("n");

for(j=0;jj++)

{

a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;

k=i;

printf("kemu is %d:n",j);

for(i=0;ii++)

学生管理系统 c语言源代码

{b=stu[i].score[j]/10;

if(b6)

a5++;

else

if(b=6b7)

a6++;

else

if(b=7b8)

a7++;

else

if(b=8b9)

a8++;

if(b=9b10)

a9++;

else

if(b==10)

a10++;

}

printf(" 不及格 is %dn",a5);

printf(" 60--69 is %dn",a6);

printf(" 70--79 is %dn",a7);

printf(" 80--89 is %dn",a8);

printf(" 90--99 is %dn",a9);

printf(" 100 is %dn",a10);

}

}

main()

{

int a;

printf(" ____n"); printf(" 欢迎进入学生成绩管理系统n");

printf(" ____n"); while(1)

{printf("n选择菜单:n");

printf("n");

printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出n");

scanf("%d",

switch(a)

{case 1: shuru();break;

case 2: chaxun(); break;

case 3: paixu(); break;

case 4: xiugai(); break;

学生管理系统 c语言源代码

case 5: tongji();break; case 6: exit(0); }


本文标签: 管理系统 学生 语言