问题 填空题

若给fun函数的形参s传送字符串“∪∪6354’abc"(其中∪表示空格字符),则函数的返回值是 【19】
long fun(char s[])
long n; int sign;
for(;isspace(*s);s++);
sign=(*s==’-’) -1:1;
if(*s==’+’||*s==’-’) s++;
for(n=0;isdigit(*s);s++)
n=10*n+( *s-’0’);
return sign*n;

答案

参考答案:6354

解析: 函数fun的第一个for循环跳过字符串的前导空白符,接着判断第一个非空白符是否是负号,若是,则置变量sign为-1;否则,置变量sign为1。接着的if语句在第一个非空白字符是负号或正号时,跳过该字符。以后的for循环将后面的数字符当作十进制数的各位数字转换为一个长整数n,当遇字符a时,结束循环。最后,函数返回sign与n的乘积。所以若调用函数时提供的实参是“∪∪6354abc”,则函数的返回值是6354。

完形填空
完形填空。
     Many people who work in London want to live outside it and to go to their offices, factories or schools
every day by train, car or bus, even though this   1   they have to get up earlier in the morning and reach   2   
later in the evening.
     One benefit (好处) of living outside London is that houses are   3  . Even a small flat (公寓) in London
without a garden costs quite a lot   4  . With the same money, one can get a little house in the country with
a garden of   5   own. Then, in the country one can be   6   from the noise and hurry of the town.   7   one
has to get up earlier and spend more time in trains or buses, one can sleep   8   at night, and, during weekends
and   9   summer evenings, one can enjoy the  10  air of the country. If one  11  gardens, one can spend one's 
 12  time digging, planting, watering and doing the hundred and one other jobs which are  13  in the garden.
Then, when the flowers and vegetables  14 , one has the reward (回报) of a person who has shared the secrets
of  15 .
     Some people, however, take no interest in country things; for them,  16  lies in the town, with its cinemas
and theatres, beautiful shops and busy streets, dance halls and restaurants. Such people would  17  that their
life was not worth  18  if they had to live it outside London. A walk in one of the parks and a visit  19  the sea
every summer is all the country they  20 .
( )1. A. shows  
( )2. A. home   
( )3. A. cleaner
( )4. A. to sell
( )5. A. him    
( )6. A. free   
( )7. A. If     
( )8. A. little  
( )9. A. on     
( )10. A. cold   
( )11. A. prefers
( )12. A. day    
( )13. A. made   
( )14. A. come on
( )15. A. work   
( )16. A. health 
( )17. A. know   
( )18. A. wasting
( )19. A. for    
( )20. A. hope   
B. expresses   
B. family      
B. nicer       
B. to lend     
B. its       
B. far        
B. Although   
B. less        
B. for        
B. warm       
B. likes      
B. rest        
B. brought  
B. come to      
B. society    
B. happiness  
B. feel        
B. finding     
B. to        
B. wish     
C. means        
C. flat        
C. bigger      
C. to borrow  
C. one's      
C. out      
C. Because    
C. longer        
C. at        
C. fresh         
C. wants    
C. spare       
C. carried     
C. come up      
C. science   
C. wealth      
C. understand   
C. living     
C. of         
C. ask      
D. needs          
D. house       
D. cheaper       
D. to hire        
D. their       
D. absent       
D. After         
D. better           
D. by        
D. pleasant        
D. interests  
D. whole         
D. needed       
D. come over                  
D. nature     
D. future       
D. hope           
D. spending    
D. at           
D. want      
单项选择题 B型题