问题 单项选择题

程序如下: SET TALK OFF INPUT TO X FOR i=1 TO 3INPUT TO YIF Y>X X=Y ENDIF ENDFOR X RETURN 本程序的功能是( )。

A.求3个数中的最大值

B.求4个数中的最大值

C.求3个数中的最小值

D.求4个数中的最小值

答案

参考答案:B

解析: FOR-ENDFOR语句通常用于实现循环次数已知情况下的循环结构。 FOR-ENDFOR语句的格式: FOR<循环变量>=<初值>TO<终值>[STEP<步长>]<循环体> ENDFORINEXT 执行该语句时,首先将初值赋给循环变量,然后判断循环条件是否成立(若步长为正值,循环条件为<循环变量><=<终值>;若步长为负值,循环条件为<循环变量>>=<终值>)。若循环条件成立,则执行循环体,然后循环变量增加一个步长值,并再次判断循环条件是否成立,以确定是否再次执行循环体。若循环条件不成立,则结束该循环语句,执行ENDFOR后面的语句。 分析题干可知,将第一次输入的值赋给变量X,使用FOR循环连续输入值,当输入第二个值时,将此值赋给变量Y,然后比较x与Y的大小.如果Y>X,则X就等于第二次输入的值.否则X的值不变,接着输入第三个值,将此值赋给变量Y,然后比较X与Y的大小,如果Y>X,则X就等于第三次输入的值,否则X的值不变,接着输入第四个值,将此值赋给变量Y,然后比较X与Y的大小,如果Y>X,则X就等于第四次输入的值,否则X的值不变。最终输出的是输入的四个数中最大的那个数值。

阅读理解

阅读理解。

     In most parts of the world, many students help their schools make less

pollution(污染).They join "environment(环境)club".In an environment

club,people work together to make our environment clean.

     Here are some things students often do.

     No - garbage(垃圾)lunches.How much do you throw away after lunch?Environment clubs ask students to bring their lunches in bags that can be

used again.Every week they will choose the classes that make the least

garbage and report them to the whole school.

     No - car day.On a no-car day,nobody comes to school in a car not the

students and not the teachers.Cars give pollution to our air,so remember:

walk,jump,bike,or run! Use your legs! It's lots of fun!

     Turn off the water! Did you know that toilets(抽水马桶)can waste twenty to forty tons(吨)of water an hour?In a year,that would fill in a small river! In the environment clubs,students mend those broken toilets.

     We love our environment.Let's work together to make it clean.

1.Environment clubs ask students ________

A.to run to school every day.    

B.to take exercise every day.

C.not to throw away lunch bags.

2.From the passage we know the students usually have lunch ________.

A.at school    

B.in shops    

C.in clubs

3.On a no-car day,________ will take a car to school.

A.both students and teachers    

B.only students

C.neither students nor teachers

4.After students mend toilets,they save ________.

A.a small river    

B.a club    

C.a lot of water

5.The writer wrote the passage to ask students to ________.

A.clean school    

B.make less pollution

C.join clubs

多项选择题