三九宝宝网宝宝百科宝宝知识

全国计算机等级考试二级C语言上机题52

10月30日 编辑 39baobao.com

[职称英语等级考试模拟题理工类AB级]第1部分 词汇 选择(第1-15题,每题1分,共15分,建议10分钟以内完成)下面共有15句子,每个句子均有一个词或短语划有底横线,请从每个句子后面所给的四个选项中选择一个与划线部分意义...+阅读

题目52

已知数据文件in.dat中存有200个四位数,并已调用读函数readdat()把这些数存入数组a中,请考生编制一函数jsval(),其功能是:把千位数字和个位数字重新组成一个新的十位数(新十位数的十位数字是原四位数的千位数字,新十位数的个位数字是原四位数的个位数字),以及把百位数字和十位数字组成另一个新的十位数(新十位数的十位数字是原四位数的百位数字,新十位数的个位数字是原四位数的十位数字),如果新组成的两个十位数均是奇数并且两个十位数中至少有一个数能被5整除,同时两个新数的十位数字均不为零,则将满足此条件的四位数按从大到小的顺序存入数组b中,并要计算满足上述条件的四位数的个数cnt。后main()函数调用写函数writedat( )把结果cnt以及数组b中符合条件的四位数输出到out.dat文件中。

 注意:部分源程序存在文件prog1.c中。

 程序中已定义数组:a[200],b[200],已定义变量:cnt

 请勿改动数据文件in.dat中的任何数据、主函数main()、读函数readdat()和写函数writedat()的内容。



&emspinclude

&emspdefine max 200



int a[max], b[max], cnt = 0 ;



void jsval()

{int i,thou,hun,ten,data,j;

 int ab,cd;

 for(i=0;i {thou=a[i]/1000; hun=a[i]%1000/100;

 ten=a[i]%100/10; data=a[i]%10;

 ab=10*thou+data; cd=10*hun+ten;

 if(ab%2

 }

 for(i=0;i for(j=i+1;j if(b[i]}



void readdat()

{

 int i ;

 file *fp ;

 fp = fopen("in.dat", "r") ;

 for(i = 0 ; i< max ; i++) fscanf(fp, "%d",

 fclose(fp) ;

}



void main()

{

 int i ;

 readdat() ;

 jsval() ;

 printf("满足条件的数=%d\n", cnt) ;

以下为关联文档:

职称英语等级考试模拟题综合类AB级第1部分 词汇 选择(第1-15题,每题1分,共15分,建议10分钟以内完成)下面共有15句子,每个句子均有一个词或短语划有底横线,请从每个句子后面所给的四个选项中选择一个与划线部分意义...

2009年度全国职称外语等级考试用书目录书 名 单价(元) 订数(册) 全国专业技术人员职称英语等级考试大纲 20 全国专业技术人员职称日语等级考试大纲 18 全国专业技术人员职称俄语等级考试大纲 11 全国专业技术人员职称...

全国职称外语等级考试综合类概括大意7PASSAGE 14  Earthquake Every year earthquakes are responsible for a large number of deaths and a vest amount of destruction in various parts of the world. Mos...

全国职称外语等级考试综合类概括大意2PASSAGE 3  Science Fiction Amongst the most popular books being written today are those which are usually classified as science fiction. Hundreds of titles ar...

全国职称外语等级考试综合类概括大意3PASSAGE 5  Recreation and Sports “All work and no play makes Jack a dull boy” is a popular saying in the United States. Other countries he similar sayings....

全国职称外语等级考试综合类概括大意6PASSAGE 12  Adult Education Voluntary learning in anized courses by mature men and women is called adult education. Such education is offered to make people a...

全国职称外语等级考试综合类概括大意4PASSAGE 8  Radio and Television There are few homes in Britain today that do not he either a radio or television set. Both of them he bee an essential part of...

全国职称英语等级考试阅读题Passage 2 Football is, I believe, the most popular game in England: one has only to go to one of the important matches to see this. Rich and poor, young and old...

全国职称外语等级考试综合类概括大意1PASSAGE 1  Successful Language Learners Some people seem to he a knack for learning languages. They can pick up new vocabulary, master rules or grammar, and lea...

推荐阅读
图文推荐