第二周作业

一、实验代码

include<stdio.h>

include<stdlib.h>

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

二、设计思路
1、先定义变量
2、 再输入数组
3、使用for循环语句
4、最后输出结果
三、流程图

四、结果图

原文地址:https://www.cnblogs.com/zhouhuahua/p/10501731.html