试题与答案

下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请

题型:填空题

题目:

下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在横线处填上适当内容,实现该函数。
bool fun(char *str)

int i=0,j=0;
while(str[j])______;
for(j--;i<j && str [i]==str[j];i++,j--);
return i______j;

答案:

参考答案:j++;i>=j

解析: 本题考核while循环语句和for循环语句。题中函数的功能是判断字符串str是否对称,while循环语句的作用是将j移到字符串str的末尾那么当字符str[j]不等于 ’\0’时,j应该加1。当str对称时,for循环结束的条件应该是i>=j,所以最后的空格处应填入i>=j。

试题推荐
题型:填空题

根据句意和单词首字母提示写单词。

1. There are many apples o________ the tree.

2. Is that a TV o________ a computer?

3. Is it a map o________ Shanghai?

4. You can't see the balls because they are b________ the sofa.

5. Who's the man n________ the window?

6. Please t________ these new books to your classroom.

7.—Where's my cat?

   —It's on the f________.

8. Look! The soccer ball is u________ the chair.

9. Please put the table b________ the two chairs.

10. There are two doors i________ the wall.

查看答案
微信公众账号搜索答案