首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
文件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
51
问题
文件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://jikaoti.com/ti/c8R7FFFM
本试题收录于:
三级网络技术题库NCRE全国计算机三级分类
0
三级网络技术
NCRE全国计算机三级
相关试题推荐
在电子商务活动中,______是电子商务的高级阶段和最终目的。
对于复杂的计算机网络协议最好的组织方式是层次结构模型。我们将计算机网络层次结构模型和各层协议的集合定义为【 】。
机群系统可以按应用或结构进行分类,按应用目标可以分为高性能机群与
有—种攻击不断对网络服务系统进行干扰,改变其正常的作业流程,执行无关程序使系统响应减慢甚至瘫痪。它影响正常用户的使用,甚至使合法用户被排斥而不能得到服务。这种攻击叫做【 】。
某用户在域名为wuyouschool.com.cn的邮件服务器上申请了—个账号,账号名为huang,则该用户的电子邮件地址是______。
在直接交换方式中,局域网交换机只要接受并检测到目的地址字段,就立即将该帧转发出去,而不管这—帧数据是否出错。帧出错检测任务由以下哪种设备完成______。
下列对于网系统的防火墙的描述错误的是
下列选项中,不属于电子商务对安全的基本要求的特性是
千兆以太网的传输速率比快速以太网快10倍,数据传输速率达到【 】。
随机试题
选项所列情形中,哪些构成生产销售伪劣产品罪()
A.溶酶体B.内质网C.线粒体D.细胞液(2007年第114题)胆固醇合成和磷脂合成的共同代谢场所是
预防头癣的最佳措施是()
根据相关法规以及《标准施工招标资格预审文件》中的规定,采用()的资格预审方法的,凡符合资审文件中规定的初步审查标准和详细审查标准的申请人均为资格预审合格人。
阿兰索在假定开支总数不超出收入的前提下,对于单个家庭进行分析,认为区位平衡的取得取决于土地数量、其他商品的数量之间比例的确定。
下列选项中,由有限责任公司股东会行使的职权包括()。
某企业年销售收入为2000万元,净利润为1000万元,应收账款余额的年初数和年末数分别为105万元、95万元,该公司年应收账款周转天数为()。
“动之以情,晓之以理,导之以行,持之以恒”的做法主要反映了哪一德育过程规律?()
ReadingPassage2hassevenparagraphs,A-G.Whichsectioncontainsthefollowinginformation?Writethecorrectletter,A-G,in
StrategiesforWritingaLiteratureReviewAliteraturereviewdiscussespublishedinformationinaparticularsubjectarea.
最新回复
(
0
)