第二次编程总结

(1)实验代码

include<stdio.h>

include<stdlib.h>

int main() { FILE *fp; char sz[10]; int i,max=0,n;

if((fp=fopen("D:\\sakura.txt","a+"))==NULL)
{
    printf("找不到该文件\n");
    exit(0);
}

fscanf(fp,"%d",&n);

for(i=0;i<n;i++)
{
    fscanf(fp,"%d ",&sz[i]);
}
for(i=0;i<n;i++)
{
    if(sz [i] >sz [max])
    max=i;
}
fprintf("\n%d %d", sz [max],max);

if(fclose(fp)){
    printf("文件关不了啊!\n");
    exit(0);
}
return 0;

posted @ 2019-03-09 19:52  6497694  阅读(89)  评论(1编辑  收藏  举报