1)实验代码
include<stdio.h>
include<stdlib.h>
int main()
{
FILE * fp;
int i,index;
int a[10];
if((fp=fopen("C://Users//LCTS//Desktop//lichen//lichen.txt","a+"))==NULL)
{
printf ("File open error!
");
exit (0);
}
for(i=0;i<10;i++){
fscanf(fp,"%d",&a[i]);
}
index=0;
for(i=1;i<10;i++){
if(a[i]>a[index])
index=i;
}
printf("%d %d",a[index],index);
fprintf(fp,"
%d %d",a[index],index);
if (fclose (fp)) {
printf ("Can not close the file!
");
exit (0);
}
return 0;
}
2)思路
3)
发现有个字母打错了
4)
对于这次作业,自我感觉有点难。写了4,5个小时。