首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
文件IN.DAT中存有200个整数,函数read_dat(int inBuf[MAX])负责将这200个数读到数组inBuf[]中。请编制程序,要求;求出数组inBuf[]中最大数max及最大数的个数count和数组inBuf[]中能被3整除或能被7整除的
文件IN.DAT中存有200个整数,函数read_dat(int inBuf[MAX])负责将这200个数读到数组inBuf[]中。请编制程序,要求;求出数组inBuf[]中最大数max及最大数的个数count和数组inBuf[]中能被3整除或能被7整除的
admin
2012-07-20
38
问题
文件IN.DAT中存有200个整数,函数read_dat(int inBuf[MAX])负责将这200个数读到数组inBuf[]中。请编制程序,要求;求出数组inBuf[]中最大数max及最大数的个数count和数组inBuf[]中能被3整除或能被7整除的数的算术平均值average(保留2位小数),结果输出列OUT.DAT中。
部分程序、读函数read_dat(int inBuf[MAX])及输出格式已给出。
试题程序;
#include
#include
#define MAX 200
void read dat(int inBuf[MAX])
{
int i,j;
FILE*fp;
fp=fopen("IN.DAT","r");
for(i=0;i<20;i++)
{
for(j=0;j<10;j++)
{
fscanf(fp,"%d,",&inBuf[i*10+
j]
}
printf("%d",inBuf[i*10+j]);
}
printf("n");
}
fclose(fp);
}
void maln()
{
int count,inBuf[MAX],max;
float average;
FILE*fw;
int i,k=0;
long j;
system("CLS");
fw=fopen("OUT.DAT","w");
read dat(inBuf);
average=0;count=0;max=0;j=0;
printf("\n\nmax=%d,count=%d,aver
age=%6.2f\n",max,count,average);
fprintf(fw,"%d\n%d\n%6.2f\n",max,
count,average);
fclose(fw);
}
选项
答案
for(i=0;i
max) //如果某个数比先前确定的最大值大 max;inBuf[i]; //则将该数设为新的最大值 for(i=0;i
解析
本题主要考查依据数组下标对数据进行筛选及平均值的求法。程序基本步骤是;1.对200个整数进行遍历,求出最大值max,再统计出最大值的个数。2.求出能被3或7整除的数,所以两个条件之间用"或"运算,将满足条件的数累加到j中。3.最后用j/k求其平均值。
转载请注明原文地址:https://kaotiyun.com/show/524Z777K
本试题收录于:
三级网络技术题库NCRE全国计算机三级分类
0
三级网络技术
NCRE全国计算机三级
相关试题推荐
目前常见的VideoCD(VCD)视频数据所采用的数据压缩格式是【 】。
B-ISDN中的ISDN的意思是综合业务数字网(IntegratedServiceDigitalNetwork),而B的意思是【 】。
环型拓扑的优点是结构简单,实现容易,传输延迟确定,适应传输负荷较重,【 】要求较高的应用环境
下列不属于从通信网络的传输方面对加密技术分类方式的是
长期以来,网络操作系统的3大阵营是Novell的NetWare和Ⅰ.MicroSoft的WindowsNTⅡ.MicroSoft的Windows2000Ⅲ.UNIXⅣLinux
在双绞线组网的、方式中,以太网的中心连接设备是
某用户在域名为wuyouschool.com.cn的邮件服务器上申请了—个账号,账号名为huang,则该用户的电子邮件地址是______。
常用的电子支付方式包括电子现金、【 】和电子支票。
D数据报报头中有两个长度域,一为报头长度,一为总长度。报头长度以位为单位,总长度以______位为单位。
目前,在覆盖范围比较小的局域网中使用双绞线,在远距离传输中使用______的趋势已经明朗。
随机试题
水泥粉煤灰碎石桩(CFG桩)施工前应选择有代表性的地段进行工艺性试验,确定主要工艺参数,并报()。
6个月女婴,因腹泻2周用抗生素治疗无显效,近3d来纳差,伴轻吐。查口腔见颊黏膜上有白色乳凝块样物,不易拭去,诊断为鹅口疮。下列各项均为对该病的正确描述,除了
在糖酵解和糖异生中均起作用的酶是
抗菌药物在外科疾病应用中,下列哪项叙述错误
证券投资基金的专业管理特点决定其收益比普通投资者自行投资证券具有更高的收益。()
计算个人所得税综合所得应纳税所得额时,下列支出不得扣除的是()。
甲、乙双方签订一份销售10辆汽车的合同,由此形成的经济法律关系客体是()。
下列关于制定幼儿一日生活日程的叙述,错误的是()。
《陕甘宁边区施政纲领》增加了()等崭新的内容。
WhenPaulGorski,thefounderofanorganizationcalledEdChange,visitscollegesanduniversitiestoadvisethemoncampusdive
最新回复
(
0
)