---恢复内容开始---
includeif((fp=fopen("C:cyy.txt","r+"))==NULL)
{
printf("File open error!
");
exit (0);
}
for(i=0;i<6;i++)
{
fscanf(fp,"%d",&a[i]);
}
for(i=0;i<6;i++){
if(a[i]>a[max]) {
max=i;
}
}
printf("%d %d",a[max],max);
fprintf(fp," %d %d",a[max],max);
if(fclose (fp)){
printf("Can not close the file!
");
exit(0);
}
return 0;
}
流程图
{{uploading-image-934218.png(uploading...)}}
---恢复内容结束---
include<stdio.h>include<stdlib.h>
int main(void)
{
FILE * fp;
char a[20];
int n,i;
int max=0;
if((fp=fopen("C:cyy.txt","r+"))==NULL)
{
printf("File open error!
");
exit (0);
}
for(i=0;i<6;i++)
{
fscanf(fp,"%d",&a[i]);
}
for(i=0;i<6;i++){
if(a[i]>a[max]) {
max=i;
}
}
printf("%d %d",a[max],max);
fprintf(fp," %d %d",a[max],max);
if(fclose (fp)){
printf("Can not close the file!
");
exit(0);
}
return 0;
}
流程图