c语言学生成绩管理要求用数组,用C语言编写学生成绩管理系统

if(studentArray[i].total_score>studentArray[j].total_score)

{

temp=studentArray[i];

studentArray[i]=studentArray[j];

studentArray[j]=temp;

}

if(!flag)

{

printf("%-10s%-10s%-15s%-10s",putout[8],putout[0],putout[1],putout[7]);

for(i=0;iprintf("%-10d%-10s%-15s%-10d",count-i,studentArray[i].name,studentArray[i].number,studentArray[i].total_score);

}

else

{

printf("%-10s%-10s%-15s%-10s",putout[8],putout[0],putout[1],putout[7]);

for(i=count-1;i>=0;i--)

printf("%-10d%-10s%-15s%-10d",count-i,studentArray[i].name,studentArray[i].number,studentArray[i].total_score);

}

break;

return ;

}

}

//输出不及格学生的相关信息

void printUnpassed()

{

FILE *fp;

int i;

int total=0;

fp=fopen("e:\\student.txt","rb");

if(count==0)

{

printf("没有学生信息,即将退出");

return ;

}

printf("不及格学生相关信息如下所示");

printf("%-10s%-15s%-20s%-5s",putout[0],putout[1],putout[2],putout[3]);

printf("%-6s%-6s%-6s%-6s", putout[4],putout[5],putout[6],putout[7]);

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

if(judge(studentArray[i].c_score)+judge(studentArray[i].english_score)+judge(studentArray[i].math_score)>3)

{

printf("%-10s%-15s%-20s",studentArray[i].name,studentArray[i].number,studentArray[i].specialty);

printf("%-5s",studentArray[i].sex);

printf("%-6d%-6d",studentArray[i].c_score,studentArray[i].english_score);

printf("%-6d%-6d",studentArray[i].math_score,studentArray[i].total_score);

printf("");

total++;

}

printf("不及格学生人数共有%d人",total);

return ;

}

//输出文件中所有学生信息记录

void printAll()

{

FILE *fp;

int i;

//student buffer;

fp=fopen("e:\\student.txt","rb");

if(count==0)

{

printf("现在还没有学生记录,即将退出");

printf("");

return ;

}

printf("该文件中一共有%d个学生记录,记录如下:",count);

printf("%-10s%-15s%-20s%-5s",putout[0],putout[1],putout[2],putout[3]);

printf("%-6s%-6s%-6s%-6s", putout[4],putout[5],putout[6],putout[7]);

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

{

printf("%-10s%-15s%-20s",studentArray[i].name,studentArray[i].number,studentArray[i].specialty);

printf("%-5s",studentArray[i].sex);

printf("%-6d%-6d",studentArray[i].c_score,studentArray[i].english_score);

printf("%-6d%-6d",studentArray[i].math_score,studentArray[i].total_score);

printf("");

}

}

void clear()

{

FILE *fp;

char ch;

printf("你确认删除所有学生记录吗?继续输入y活着Y");

fflush(stdin);

ch=getchar();

if(ch==''y''||ch==''Y'')

{

fp=fopen("e:\\student.txt","wb");

count=0;

}

return ;

}

//主函数

int main()

{

int choice;

printf("**************************欢迎进入学生信息管理系统******************************");

initial();

while(1)

switch(choice=menuselect())

{

case 0:

printf("************************欢迎下次再次使用*********************");

exit(0);

case 1:

addStudent();

break;

case 2:

delStudent();

break;

case 3:

modifyStudent();

break;

case 4:

searchStudent();

break;

case 5:

studentProfile();

break;

case 6:

setOrder(0);

break;

case 7:

setOrder(1);

break;

case 8:

printUnpassed();

break;

case 9:

printAll();

break;

case 10:

system("CLS");

//clrscr();

break;

case 11:

clear();

break;

}

return 0;

}

//菜单函数

int menuselect()

{

int choice;

do

{

printf("0.退出管理系统");

printf("1.添加学生信息记录");

printf("2.删除某一指定学生记录");

printf("3.修改某一给定学生信息");

printf("4.查找某一给定学生信息");

printf("5.输出学生信息总体概况");

printf("6.按照分数从低到高输出学生相关信息");

printf("7.按照分数从高到低输出学生相关信息");

printf("8.输出不及格学生的相关信息");

printf("9.输出文件中所有学生的记录");

printf("10.清屏");

printf("11.删除所有学生记录");

printf("输入你的选择:");

scanf("%d",&choice);

}while(choice<0||choice>11);

return choice;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值