九、设名为“d:\s_total.dat”的二进制中按照下列结构型
来源:百度知道 编辑:UC知道 时间:2024/05/24 08:56:32
九、设名为“d:\s_total.dat”的二进制中按照下列结构型,依次存放了100个学生的信息。编一个程序,从中找出总分最高和总分最低的学生,并且输出它们的学号、姓名和总分。
struct { long num ; char name[20] ; float total ; } ;
struct { long num ; char name[20] ; float total ; } ;
/*******************************************************************************
设名为“d:\s_total.dat”的二进制中按照下列结构型,
依次存放了100个学生的信息。编一个程序,从中找出总分
最高和总分最低的学生,并且输出它们的学号、姓名和总分。
struct { long num ; char name[20] ; float total ; } ;
*******************************************************************************/
#include <stdio.h>
struct
{
long num;
char name[20];
float total;
}max,min,tmp;
void main()
{
FILE *fp;
/*打开文件*/
if((fp=(fopen("d:\\s_total.dat","rb")))==NULL)
{
printf("Open file failed.\n");
return;
}
&n