问题 填空题

下面程序的功能是将一个字符串str的内容颠倒过来,请填空。
#include<string.h>
main()
inti,j, 【8】 ;char str[]="1234567";
for(i=0,j=strlen(str) 【9】 ;i<j;i++,j--)
k=str[i];str[i]=str[j];str[j]=k;
printf("%s\n",str);

答案

参考答案:[8]k [9]-1

解析: 颠倒一个字符串中的字符,就是首尾对应的元素两两交换。简单地可用两个游标变量i和j,i是前端元素的下标,j是后端元素的下标,交换以这两个变量值为下标的元素str[i]和str[j]。开始时,i的值为 0,j的值为字符串末元素的下标(字符串长度减1)。每次交换后,i增1,j减1。继续交换的条件是str[i]还位于str[j]的前面,即i<j。字符串末元素的下标是它的长度减1,所以在第二个空框处应填入-1。程序为了交换str[i]和str[j],使用了变量k,该变量应在程序的变量定义部分中一起定义,所以在第一个空框处应填入k。

阅读理解

“The pen is more powerful than the sword(剑).” There have been many writers who used their pens to fight things that were wrong. Mrs Harriet Beecher Stowe was one of them. She was born in the U.S.A. in 1811.One of her books not only made her famous but has been described as one that excited the world, and was helpful in causing a civil war and freeing the enslaved race. The civil war was the American Civil War of 1861,in which the Northern States fought the Southern States and finally won.

This book that shook the world was called Uncle Tom’s Cabin. There was a time when every English-speaking man, woman, and child has read this novel that did so much to stop slavery. Not many people read it today, but it is still very interesting. The book has shown us how a warm-hearted writer can arouse(唤起) people’s sympathies. The author herself had neither been to the Southern States nor been a slave. The Southern Americans were very angry at the book, which they said did not at all represent true state of affairs, but the Northern Americans were wildly excited over it and were so inspired by it that they were ready to go to war to set the slaves free.

41.According to the passage______.

A.every English-speaking person has read Uncle Tom's Cabin

B.Uncle Tom's Cabin was not very interesting

C.those who don't speak English cannot have read Uncle Tom's Cabin

D.the book Uncle Tom's Cabin did a great deal in the American Civil War

42.How old was Mrs Harriet Beecher Stowe when her world famous book was published?

A.About sixty years old.    B.Over fifty years old.

C.In her forties.           D.Around twenty years old. 43.What do you learn about Mrs Harriet Beecher Stowe from the passage?        

A.She had been living in the north of America before the American Civil War 

broke out.

B.She herself encouraged the Northern Americans to go to war to set the slaves free.

C.She was better as writing as swinging(挥舞)a sword.

D.She had once been a slave.

44.What can we learn from the passage?  

A.We needn’t use weapons to fight things that are wrong.

B.A writer is more helpful in a war than a soldier.

C.We must understand the importance of literature and art.  

D.No war can be won without such a book as Uncle Tom's Cabin .

单项选择题