问题 问答题

请编写函数fun(),其功能是:将所有大于1小于整数m的素数存入xx所指数组中,素数的个数通过k传回。 例如,输入25,则应输出2 3 5 7 11 13 17 19 23。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include<conio.h> #include<stdio.h> void fun(int m,int *k,int xx[ ]) { } main( ) { int m,n,zz[100]; clrscr( ); printf("/nPlease enter an integer number between 10 and 100:"); scanf("%d",&n); fun(n,&m,zz); printf("\n\nThere are%d prime numbers less than %d:",m,n); for(n=0;n<m;n++) printf("\n %4d",zz[n]); }

答案

参考答案:

解析:void fun(int m,int *k,int XX[]) { int i,j,t,n=0; for(i=2;i<m;i++) /*找出大于1小于整数m的素数*/ { t=l; for(j=2;j<i;j++) if(i%j==0) { t=0; break; } if(t==1) xx[n++]=i; } *k=n; /*返回素数的个数*/ } 这道题是考查一个数是不是素数,只要掌握了判断素数的方法,问题便能顺利解决,请以此题为例,掌握判断素数的方法。

单项选择题
阅读理解

A businessman had two sons. While he gave the younger son a lot of love and gifts, he neglected (忽视) the elder son. It was completely puzzling (令人费解) and no one knew why.

When the boys grew up, they were asked to manage the father’s business. The elder son was absorbed in the business. From morning till late in the evening, he was busy working. Within a few years, he ran the business very well and even expanded (扩大) it.

What about the younger son? He didn't have much to do except have a good time. But the father believed that his favorite son would be a success. If the elder son could be a successful businessman, surely the younger one, with a higher education, would do much better.

A few years later, the results of his decision became clear. Uninterested in business, the younger son continued spending his time enjoying himself. And he went out of business. But the elder son’s far smaller share (份) of business had expanded and he had proved himself to be a good decision maker.

Ashamed at the turn of events, the father met the elder son and was angry with the younger one. The elder son, who was listening to all this quietly, suddenly said he wanted to set up an independent business and live on his own.

“Why?” asked the father.

“I blame (责备) one person for the way my brother has turned out, and it’s not him. You can’t blame children for the faults (过失) of their parents, can you?” asked the elder son.

小题1:Before the younger son went into the father’s business, he______.

A.was interested in business

B.had achieved great success

C.often looked down upon his brother

D.was well-educated at school小题2: Why did the father treat the two sons differently?

A.the elder son didn’t work hard

B.no one knew why he did it

C.the younger son was hardworking

D.he wanted to do an experiment小题3:Which is NOT the reason for the younger son’s going out of business?

A.he himself didn’t work hard

B.his father didn’t educate him properly

C.he was not interested in business at all

D.he was busy working every day小题4:What does the text really want to teach us?

A.Parents are responsible for children’s development.

B.Once something is done, you should do it well.

C.Interest is the most important for success.

D.One has responsibility for what he himself has done.