include<stdio.h>
include<stdlib.h>
int main()
{
FILE*fp;
int num[11];
int i,x;
if((fp=fopen("c:\\1111\\hsq.txt","a+"))==NULL)
{
exit (0);
}
for(i=0;i<11;i++){
fscanf(fp,"%d%c",&num[i]);
printf("%d%c",num[i]);
}
x=0;
for(i=1;i<11;i++){
if(num[i]>num[x])
x=i;
}
printf("%d %d",num[x],x);
fprintf(fp,"\n%d %d",num[x],x);
if(fclose(fp))
{
exit(0);
}
return 0;
}
流程表:
头文件#include<stdio.h>
建文件
运用file型指针
打开文件
验证
关闭文件结束