问题 单项选择题

阅读下面程序,则程序段的功能是 #include"stdio.h" main() { int c[]={23,1,56,234,7,0,34},i,j,t; for(i=1;i<7;i++) { t=c[i];j=i-1; while(j>=0&&t>c[j]) { c[j+1]=c[j];j--;} c[j+1]=t} for(i=0;i<7;i++) printf("%d",c[i]); putchar('\n');}

A.对数组元素的升序排列

B.对数组元素的降序排列

C.对数组元素的倒序排列

D.对数组元素的随机排列

答案

参考答案:B

解析: 读懂两个循环的关系,是解这个题目的关键,本题的第一个for循环的作用是实现对数组元素的遍历,第二个循环的作用是排序。while(j>=0&&t>c[j]),这个语句是控制排序的关键语句,它即实现了比较两个元素大小的作用,又实现了元素向后移动的作用,不断地把大的数据向前移动,直到找到一个比它小的,或到数据的上界为止。

选择题
阅读理解

A month after Hurricane Katrina, I returned home in New Orleans. There lay my house, reduced towaist-high ruins, smelly and dirty.

Before the trip, I’d had my car fixed. When the office employee of the garage was writing up the bill,she noticed my Louisiana license plate. “You from New Orleans?”she asked I said I was, “No charge.”She said, and firmly shook her head when I reached for my wallet. The next day I went for a haircut, and the same thing happened.

As my wife was studying in Florida, we decided to move there and tried to find a rental house that we could afford while also paying off a mortgage (抵押贷款〉on our mined house. We looked at many places, but none was satisfactory. We’d began to accept that we*d have to live in extremely reduced circumstances for a while, when I got a very curious e-mail from a James Kemmedy in California. He’d read some pieces I’d written about our sufferings for State, the online magazine  and wanted to give us (""no conditions attached’)a new house across thelake from New Orleans.

It sounded too good to be true, but I replied, thanking him for his exceptional generosity, that we had no plan to go back. Then a poet at the University of Florida offered to let his house to me, while he went to England on his one-year paid leave. The rent was rather reasonable. I mentioned the poet’s offer to James Kemdedy, and the next day he sent a check covering our entire rent for eight months.

Throughout this painful experience, the kindness of strangers has done much to bring back my faith in humanity. It’s almost worth losing your worldly possessions to be reminded that people are really nice when given half a chance.

小题1:The garage employee’s attitude toward the author was that of          

A.unconcern

B.sympathy

C.doubt

D.tolerance小题2:What do we know about James Kemnedy?

A.He was a writer of an online magazine.

B.He was a poet at the University of Florida

C.He offered the author a new house free of charge.

D.He learned about the author’s sufferings via e-mail小题3:It can be inferred from the text that         

A.the author’s family was in financial difficulty

B.rents were comparatively reasonable despite the disaster

C.houses were difficult to find in the hurricane-stricken area

D.the mortgage on the ruined house was paid off by the bank小题4:The author learned from his experience that         

A.worldly possessions can be given up when necessary

B.generosity should be encouraged in some cases

C.people benefit from their sad stories

D.human beings are kind after all.