


#include <stdio.h>
#include <stdlib.h>
#define N 10
struct student
{
int num;char name[20];int score;};
int main()
{
int i;student st,stmax,stmin;FILE *fp;stmax.score=0;stmin.score=100;fp=fopen("file1.dat","r");if(!fp)exit(0);for(i=0;i<N;i++){fscanf(fp,"%d %s %d",&st.num,st.name,&st.score);if(st.score>stmax.score)stmax=st;if(st.score<stmin.score)stmin=st;}fclose(fp);printf("high:%5d%15s%5d\n",stmax.num,stmax.name,stmax.score);printf("low:%5d%15s%5d\n",stmin.num,stmin.name,stmin.score);return 0;}
#include <stdio.h>
#include <stdlib.h>
#define N 10
struct student
{
int num;
char name[20];
int score;
};
int main()
{
int i;
student st, stmax, stmin;
FILE* fp;
stmax.score = 0;
stmin.score = 100;
fp = fopen("file1.dat", "r");
if (!fp)
exit(0);
for (i = 0; i < N; i++)
{
fscanf(fp, "%d %s %d", &st.num, st.name, &st.score);
if (st.score > stmax.score)
stmax = st;
if (st.score < stmin.score)
stmin = st;
}
fclose(fp);
printf("high:%5d%15s%5d\n", stmax.num, stmax.name, stmax.score);
printf("low:%5d%15s%5d\n", stmin.num, stmin.name, stmin.score);
return 0;
}