#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE*fp;
int i=0,max=0,j=0,maxb=0;
int b[10];
if((fp=fopen("D:\jiajia.txt","r+"))==NULL)
{
printf("File open error!
");
exit(0);
}
for (i=0;i<10;i++)
{
fscanf(fp,"%d",&b[i]);
max=0;
}
for(j=0;j<10;j++)
if( b[j]>max){
max=b[j];
maxb=j;
}
printf("%d %d",max,maxb);
fprintf(fp,"
%d %d",max,maxb);
if (fclose (fp)) {
printf ("Can not close the file!
");
exit (0);
}
return 0;
}
~~~![](https://img2018.cnblogs.com/blog/1582102/201903/1582102-20190309193621455-385703436.png)
![](https://img2018.cnblogs.com/blog/1582102/201903/1582102-20190309193626999-1802903154.jpg)