皮皮学,免费搜题
登录
搜题
【简答题】
已知数据文件IN56.DAT中存有200个4位数,并已调用读函数readDat()把这些数存入数组a中,请编制一函数jsVal(),其功能是:把千位数字和十位数字重新组合成一个新的十位数 (新十位数的十位数字是原4位数的千位数字,新十位数的个位数字是原4位数的十位数字),以及把个位数和百位数组成另一个新的十位数(新十位数的十位数字是原4位数的个位数字,新十位数的个位数字是原4位数的百位数字),如果新组成的两个十位数均为素数且新十位数字均不为零,则将满足此条件的4位数按从大到小的顺序存入数组b中,并要计算满足上述条件的4位数的个数cnt,最后调用写函数writeDat()把结果cnt及数组b中符合条件的4位数输出到OUT56.DAT文件中。 注意:部分源程序已给出。 已定义数组:a[200],b[200],已定义变量:cnt。 请勿改动主函数main()、读函数readDat()和写函数writeDat()的内容。 试题程序: include define MAX 200 int a[MAX],b[MAX],cnt=0; int isprime(int m) { int i; for(i=2;i<=m/2;i++) if(m%i==0) return 0; return 1; } void isval() { } void readDat( ) { int i; FILE *fp; fp=fopen('IN56.DAT','r'); for(i=0;i<MAX;i++) fscanf(fp,'%d',&a[i]); fclose(fp); } main() { int i; readDat(); jsVal(); printf('满足条件的数=%d/n',cnt); for(i=0;i<cnt;i++) printf('%d/n',b[i]); printf('/n'); writeDat(); } writeDat() { FILE *fp; int i; fp=fopen('OUT56.DAT','w'); fprintf(fp,'%d/n',cnt); for(i=0;i<cnt;i++) fprintf(fp, '%d/n',b[i]); fclose(fp); }
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【简答题】I think the dishwasher is a(n)______ invention. Nobody likes to wash dishes!
【单选题】在软件方面,第一代计算机主要使用
A.
计算机语言
B.
数据库系统语言
C.
汇编语言
D.
BASIC 语言
【单选题】在软件方面,第一代计算机主要使用( )
A.
机器语言
B.
高级程序设计语言
C.
数据库管理系统
D.
C语言
【简答题】What does WUHAN stand for? W--wash hands U-- H-- A-- N—
【单选题】— Ben, would you like to play football with us? — ______, but I have to wash the dishes first. [     ]
A.
No, I can't
B.
I don't want to
C.
Yes, please
D.
I'd love to
【简答题】n v. to wash sth. in clean water so as to take away soap
【单选题】---What should we do to fight A/H1N1 flu? ---We should wash hands often, avoid ______ to crowded places and so on.
A.
go
B.
going
C.
gone
D.
to go
【单选题】Ann:May I help you wash up,Mum?Mum:__________.A.Yes,you mayB.N0,you can’t
A.
Ann:May I help you wash up,Mum? Mum:__________. A.Yes,you may
B.
N0,you can’t
C.
Thank you,you’re so helpful
D.
Thanks all the same
【简答题】Task 4 You are Taylor Wang, working at Supershine Car Wash. Your shop is about to move to a new site. In order to keep its regular customers, the shop will offer a free car-wash service for the first ...
【单选题】在软件方面,第一代计算机主要使用的是
A.
机器语言
B.
高级程序设计语言
C.
数据库管理系统
D.
BASIC和FORTRAN
相关题目: