皮皮学,免费搜题
登录
搜题
【简答题】
已知数据文件IN82.DAT中存有300个4位数,并已调用函数readDat()把这些数存入数组a中,请编制一函数isValue(),其功能是:求出这些4位数是素数的个数cnt,再求出所有满足此条件的4位数的平均值pjz1,以及所有不满足此条件的4位数的平均值pjz2,最后调用函数writeDat()把结果cnt,pjz1,pjz2,输出到out82.dat文件中。 例如:5591是素数,则该数满足条件,计算平均值pjz1,且个数cnt=cnt+1。 9812是非素数,则该数不满足条件,计算平均值pjz2。 注意:部分源程序已给出。 已定义数组:a[300],b[300],已定义变量:cnt,pjz1,pjz2。 请勿改动主函数main()、读函数readDat()和写函数writeDat()的内容。 试题程序: include<stdio. h> int a[300], cnt=0; double pjz1=0.0, pjz2=0.0; int isP(int m) { int i; for (i=2; i<m; i++) if(m%i==0) return 0; return 1; } void jsValue() { } main ( ) { int i; readDat (); jsValue(); writeDat (); printf ('cnt=%d/n满足条件的平均值pjz1=%7.21f/n不满足条件的平均值 pjz2=%7.21f/n', cnt, pjz1, pjz2); } readDat ( ) { FILE *fp; int i; fp=fopen('in82.dat','r'); for (i=0; i<300; i++) fscanf (fp, '%d, ', &a [i]); fclose (fp); } writeDat () { FILE *fp; int i; fp=fopen('out82.dat','w'); fprintf(fp,'%d/n%7.21f/n%7.21f/n',cnt,pjz1,pjz2); fclose(fp); }
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【单选题】There seemed little hope that the explorers, ______ in the rainforest, would find their way out.
A.
having deserted
B.
to have been deserted
C.
to be deserted
D.
having been deserted
【单选题】There seemed little hope that the explorer,____in the tropical forest, would find bis way out.
A.
having been deserted
B.
having deserted
C.
to have been deserted
D.
to be deserted
【单选题】There seemed little hope that the explorer, ______in the tropical forest, would find his way out.
A.
having been deserted
B.
having deserted
C.
to have been deserted
D.
to be deserted
【单选题】同一会计年度内开始并完成的劳务,应当( ),确认提供劳务收入。
A.
按完工百分比法
B.
在提供劳务交易完成且收到款项或取得收款权利时
C.
在收到款项时
D.
在资产负债表日
【判断题】同一会计年度内开始并完成的劳务,应当在提供劳务交易完成且收到款项或取得收款权利时,确认提供劳务收入
A.
正确
B.
错误
【单选题】The little girl showed no anxiety before the competition. She seemed _____ for it pretty well. A
A.
26. The little girl showed no anxiety before the competition. She seemed _____ for it pretty well. A.to prepare
B.
to have prepared
C.
having prepared
D.
to be preparing
【简答题】___________ seemed a little bit ____________ (a).
【单选题】There seemed little hope that the explorer, ______in the tropical forest, would find his way through it.
A.
to be deserted
B.
having deserted
C.
to have been deserted
D.
having been deserted
【单选题】There seemed little doubt that the spread of a particular cultural trait did follow a specific regular pattern______.
A.
as a society adopted
B.
which a society adopted it
C.
as a society adopted it
D.
when a society adopted
【简答题】当连杆弯扭变形并存时,应( )
相关题目: