题目内容

已知数据文件IN11.DAT中存有300个四位数,并已调用读函数readDat()把这些数存入数组a中。请编制一个函数jsValuc(),其功能是:求出千位数上的数加个位数上的数等于百位数上的数加十位数上的数的个数cnt,再把所有满足条件的四位数依次存入数组b中,然后对数组b中的四位数按从小到大的顺序进行排序,最后调用写函数writeDat()把数组b中的数输出到OUT11.DAT文件。 例如:6712,6+2=7+1,则该数满足条件存入数组bb中,且个数cnt=cnt+1。 8129,8+9≠1+2.则该数不满足条件,忽略。 注意:部分源程序已给出。程序中已定义数组:a[300],b[300];已定义变量:cnt。请勿改动主函数main()、读函数 readDat()和写函数writeDat()的内容。 [试题程序] #include<stdio.h> int a[300],b[300],cnt=0; void jsValue() main() int i; readDat(); jsValue(); writeDat(); for(i=0;i<cn;i++)printf("b[%d]=%d\n",i,b[i]); readDat() FILE *fp; int i; fp=open("IN11.DAT","r"); for(i=0;i<300;i++)fscanf(fp,"%d,",&a[i]); fclose(fp); writeDat() FILE *fp; Int i; fp=fopen("OUT11.DAT","Wt"); fprmt(fp,"%d\n",cnt); for(i=0;i<cnt;i++)fPrIntf(fp,"%d\n",b[i]); fclose(fp);

查看答案
更多问题

Questions 19 to 22 are based on the conversation you have just heard.

A. Give up one or two and focus on Chemistry this term.
B. Ask the man for advice.
C. Cancel the three chosen courses.
D. Choose the courses in the following semester.

Passage Three Questions 33 to 35 are based on the passage you have just heard.

A. Understanding different values in other cultures well.
B. Creating a multicultural environment.
C. Following the value systems of our own culture.
D. Teaching our customs to foreigners.

Passage Three Questions 33 to 35 are based on the passage you have just heard.

A. There are great differences between Thailand and English cultures.
B. The same signal may be misunderstood by people from different cultures
C. Thailand and English cultures have different value systems.
D. Requirements for talk and silence can be different in some cultures.

Questions 23 to 25 are bused on the conversation you have just heard.

A. Five hours’ walk. B. Three hours’ walk.
B. C. About an hour’s walk. D. A couple of minutes’ walk.

答案查题题库