⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 学生成绩管理系统2.0修改版.c

📁 刚作的可以管理学生的成绩,及其成绩的平均分.排序.
💻 C
📖 第 1 页 / 共 2 页
字号:
				fwrite(&a,sizeof(struct i),1,fp3);return;		//写入平均值
			}										
		}
		fclose(fp3);return;											//关闭文件
}
void ok3(int x)
{	float h;
	struct x
	{
		char a1[6];
		int a2;
		float c;
		float sql;
		float vb;
	}s,z;
	FILE *fp;
	if((fp=fopen("score.dat","r+b"))==NULL)
		{system("cls");
		printf("很抱歉,没有找到您所需要的文件...\n"
			"请按任意键重新选择您所需要使用的功能...");
		getch();
			return;}
	system("cls");
	printf("                      修改学生成绩\n\n");
	printf("请您输入要修改的班级名称和学号:");
	scanf("%5s%d",s.a1,&s.a2);printf("\n");
	printf("        请您重新输入C语言的成绩:		");
	scanf("%f",&s.c);
	printf("        请您重新输入SQL语言的成绩:	");
	scanf("%f",&s.sql);
	printf("        请您重新输入VB语言的成绩:		");
	scanf("%f",&s.vb);
	h=(s.c+s.sql+s.vb)/3;
	p3(s.a1,s.a2,h);
	while(fread(&z,sizeof(struct x),1,fp)==1)
		if((strcmp(s.a1,z.a1)==0)&&(s.a2==z.a2))
		{
			fseek(fp,-24,1);		
			fwrite(&s,sizeof(struct x),1,fp);
		}	
	printf("\n\n\t\t==========恭喜您!!成绩修改成功!==========\n\n");
	printf("请您按任意键返回上一级菜单继续使用其他功能......");
	fclose(fp);
	getch();
	return;
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
void ok4(int x)
{
	char b[6];
	int i;
	struct t                        //定义结构体存文件的资料
	{
		char a1[6];
		int a2;
		char a3[20];
		float a4;
	}a,c;
	struct x
	{
		char a1[6];
		int a2;
		float c;
		float sql;
		float vb;
	}s,z;
	FILE *fp;
	FILE *fq;
	if((fp=fopen("score.dat","r+b"))==NULL)
		{system("cls");
		printf("很抱歉,没有找到您所需要的文件...\n"
			"请按任意键重新选择您所需要使用的功能...");
		getch();
			return;}
		s.a1[0]='@';
		s.a1[1]='\0';
		s.a2=99;
		s.c=s.sql=s.vb=0.0;
		system("cls");
		printf("                删除学生全部信息\n");
		printf("请您输入要删除的班级名称和学号:");
		scanf("%5s %d",b,&i);
		
		while(fread(&z,sizeof(struct x),1,fp)==1)
		if((strcmp(b,z.a1)==0)&&(i==z.a2))
		{
			fseek(fp,-24,1);		
			fwrite(&s,sizeof(struct x),1,fp);
			fclose(fp);
			break;
		}
		fclose(fp);
		if((fq=fopen("info.dat","r+b"))==NULL)
		{system("cls");
		printf("很抱歉,没有找到您所需要的文件...\n"
			"请按任意键重新选择您所需要使用的功能...");
		getch();
			return;}
		a.a1[0]='@';
		a.a1[1]='\0';
		a.a2=99;
		a.a3[0]='#';
		a.a3[1]='\0';
		a.a4=0.0;
		while(fread(&c,sizeof(struct t),1,fq)==1)
			if((strcmp(b,c.a1)==0)&&(i==c.a2))
		{
			fseek(fp,-36,1);		
			fwrite(&a,sizeof(struct t),1,fq);
			fclose(fq);
			break;
		}
		printf("\n\n\t\t==========恭喜您!!信息已被成功删除!==========\n\n");
		printf("请您按任意键返回上一级菜单继续使用其他功能......");
		fclose(fq);
		getch();
		return;
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
void ok5(int x)
{
	struct stu
	{
		char a1[6];
		int a2;
		char a3[20];
		float a4;
	};
 	FILE *fp;
	char xa[6];
	struct stu s;
	if ((fp=fopen("info.dat","rb"))==NULL)
	{	system("cls");
		printf("很抱歉,没有找到您所需要的文件...\n"
			"请按任意键重新选择您所需要使用的功能...");
		getch();
			return;}
	system("cls");
	printf("                  按[班级]查询学生信息\n\n");
	printf("请您输入要查询班级名称:");
	scanf("%5s",xa);
	printf("	学号\t姓名\t平均成绩\n");
	while(fread(&s,sizeof(struct stu),1,fp)==1)
		if((strcmp(xa,s.a1))==0)
	{
		printf("	%d\t%s\t%f\n",s.a2,s.a3,s.a4);
	}
		printf("\n请您按任意键返回上一级菜单继续使用其他功能......");
		fclose(fp);
		getch();
		return;
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
void ok6(int x)
{
		struct i                    //定义结构体储存文件内容
	{
		char a1[6];  
		int a2;
		float c;
		float sql;
		float vb;
	}s;
	FILE *fp2;
	char xv[6];
		if ((fp2=fopen("score.dat","rb"))==NULL)    //打开score.dat文件
			{
			system("cls");
				printf("很抱歉,没有找到您所需要的文件...\n"
			"请按任意键重新选择您所需要使用的功能...");
			getch();
			return;
		}
		system("cls");
		printf("                      按[班级]查询成绩\n");
		printf("请您输入要查询的班级名称:");
		scanf("%5s",xv);
		printf("      学号\tC成绩\t\t\tSQL成绩\t\t\tVB成绩\n");
		while(fread(&s,sizeof(struct i),1,fp2)==1)
		if((strcmp(xv,s.a1))==0)
			{
				printf("       %d\t%f\t\t%f\t\t%f\n",s.a2,s.c,s.sql,s.vb);
				
			}
		else 
		{	system("cls");
			printf("                      按[班级]查询成绩\n");			
			printf("很抱歉,没有班级的成绩......\n");
			
		}
		printf("\n请您按任意键返回上一级菜单继续使用其他功能......");
		fclose(fp2);
		getch();
		return;
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
void ok7(int x)
{	int u=0,xg,y;
	struct num
	{
		char a1[6];
		int a2;
		char a3[20];
		float a4;
	}a[100],b;
	FILE *fp;
	if((fp=fopen("info.dat","rb"))==NULL)
		{system("cls");
		printf("很抱歉,没有找到您所需要的文件...\n"
			"请按任意键重新选择您所需要使用的功能...");
		getch();
		return;
	}
	while(fread(&b,sizeof(struct num),1,fp)==1)
		if(b.a4>=60)
		{	memcpy(&a[u],&b,sizeof(struct num));
			u++;			
		}
		for(xg=1;xg<u;xg++)
	{
		for(y=u-1;y>=xg;y--)
		{
			if(a[y].a4>a[y-1].a4)
			{
				memcpy(&b,&a[y-1],sizeof(struct num));
				memcpy(&a[y-1],&a[y],sizeof(struct num));
				memcpy(&a[y],&b,sizeof(struct num));
			}
		}
	}
		if(u==0)
		{	
			system("cls");
			printf("                       显示通过考试的学生信息\n\n");
			printf("很遗憾,现在还没有及格的人...\n");
			printf("请您按任意键返回上一级菜单继续使用其他功能......");getch();
			return;
		}
			system("cls");
			printf("                       显示通过考试的学生信息\n\n");
			printf("       班级\t学号\t姓名\t平均成绩\n");
		for(x=0;x<u;x++)
			printf("       %s\t %d\t%s\t%f\n",a[x].a1,a[x].a2,a[x].a3,a[x].a4);
			fclose(fp);
			printf("\n请您按任意键返回上一级菜单继续使用其他功能......");
			getch();
			return;
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
void main()
{	
	int b=0;
	                 
	mm:	b=ok0(b);
	switch(b)
	{
		case 1: ok1(b);
				goto mm;
		case 2: ok2(b);
				goto mm;
		case 3: ok3(b);
				goto mm;
		case 4: ok4(b);
				goto mm;
		case 5: ok5(b);
				goto mm;
		case 6: ok6(b);                     
				goto mm;
		case 7: ok7(b);
				goto mm;
		case 8: 
				system("cls");
				
				printf("谢谢您的使用,请您按任意键关闭本程序...");
				getch();
				exit(1);
	}		
	
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -