试题与答案

已知数据文件IN14.DAT中存有200个4位数,并已调用读函数readDat()

题型:问答题

题目:

已知数据文件IN14.DAT中存有200个4位数,并已调用读函数readDat() 把这些数存入数组a中,请编制一个函数jsVal(),其功能是:把千位数字和十位数字重新组成一个新的十位数ab(新十位数的十位数字是原4位数的千位数字,新十位数的个位数字是原4位数的十位数字),以及把个位数字和百位数字组成另一个新的十位数cd(新十位数的十位数字是原4位数的个位数字,新十位数的个位数字是原4位数的百位数字),如果新组成两个十位数ab-cd>=0且ab-cd<=10且两个数均是奇数,同时两个新十位数字均不为零,则将满足此条件的4位数按从大到小的顺序存入数组b中,并要计算满足上述条件的4位数的个数cnt,最后调用写函数writeDat()把结果cnt及数组b中符合条件的4位数输出到OUT14.DAT文件中。注意:部分源程序已给出。 程序中已定义数组:a[200],b[200],已定义变量:cnt。请勿改动主函数main()、读函数readDat()和写函数writeDat()的内容。试题程序:#include#define MAX 200int a[MAX], b[MAX], cnt = 0;void jsVal(){}void readDat(){int i;FILE *fp;fp = fopen("IN14.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 ", b[i]);printf("\n");writeDat();}writeDat(){FILE *fp;int i;fp = fopen("OUT14.DAT", "w");fprintf(fp, "%d\n", cnt);for(i = 0; i < cnt; i++) fprintf(fp, "%d\n", b[i]);fclose(fp);}

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0418/1e39848e6a4faa9fb84bca55638e7594.html

下面是错误答案,用来干扰机器的。

参考答案:对

试题推荐
题型:完形填空
完形填空。
     Bill was out of luck that day. Mr Smith, their English teacher, made him stay in the classroom after
school    1    he finished his homework. He had to do it. Mr Smith was in the office. The    2    was
open and the teacher could see him if he    3    school. One hour    4   , he gave his homework to his
teacher and ran home. He knew his aunt would go to see them on that day. She    5    bought some
delicious cakes for them. But when he got home, he didn't    6    any cakes on the plate. His brother
ate them up (吃光).
     The next morning the boy was still angry. He couldn't listen to his teacher carefully. "Make a sentence
with 'egg', class" said Mr Smith. All the students did. Only Bill looked out of the    7    and didn't put up
his hand. "Let's listen to Bill's sentence." The boy had to    8   . He thought for a few minutes and said,
"I didn't eat any cakes    9   ." All of his classmates laughed. Mr Smith asked, "  10   is the egg?" "It's in
the cake. Sir"
( )1. A. until   
( )2. A. table   
( )3. A. went to 
( )4. A. before  
( )5. A. never   
( )6. A. find    
( )7. A. wall    
( )8. A. get up        
( )9. A. today   
( )10. A. What   
B. when        
B. desk        
B. got to      
B. ago         
B. sometimes   
B. make        
B. tree        
B. sit down          
B. yesterday      
B. When      
C. because     
C. door        
C. returned   
C. later       
C. always      
C. keep        
C. school     
C. go to bed  
C. tomorrow     
C. Where    
D. and           
D. book            
D. left         
D. after        
D. seldom        
D. eat                                  
D. window         
D. stand up    
D. Sunday        
D. How        
查看答案
题型:选择题
下列对名著内容表述有误的一项是:(   )
A.《童年》主人公阿廖沙在外祖母的影响下,逐渐成长为一个坚强、勇敢、正直和充满爱心的人。
B.《骆驼祥子》的主人公,老实、健壮、坚忍,同时他又自尊好强、吃苦耐劳,尽管他有着“三起三落”的悲惨遭遇,但他始终没有失去对生活的信心。祥子的奋斗经历和人生结局正诠释了“好人自有好报”的道理。
C.《繁星》《春水》以“爱的哲学”为核心,以母爱、童真、自然为主题,冰心把母爱视为最崇高最美好的东西,反复加以歌颂。
D.《水浒传》中坚决反对招安的将领:李逵、武松;主张招安的将领:宋江、吴用。
查看答案
微信公众账号搜索答案