lyf基础作业

include <stdio.h>

include <stdlib.h>

int main (void)
{
FILE * fp;
int a[10];
int max=0;
int i;
if ((fp=fopen("d:\lvyanfeng.txt","a+"))==NULL)
{
printf("File open error!\n");
exit(0);
}
for(i=0;i<5;i++)
fscanf(fp,"%d",&a[i]);
for(i=1;i<5;i++){
if(a[i]>a[max])
max=i;
}
printf("%d %d",a[max],max);
fprintf(fp,"\n\n%d %d",a[max],max);
if (fclose(fp)){
printf ("Can not close the file! \n");
exit (0);
}
return 0;

}
流程:

错误截图:

正确截图:

posted @ 2019-03-09 18:26  viruese-5  阅读(140)  评论(1编辑  收藏  举报