大连理工大学

I found a letter lying on the floor when I came into the classroom.()

题目

I found a letter lying on the floor when I came into the classroom.()

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下列给定函数中,函数fun()的功能是:统计字符串中各元音字母(即A,E,I,O,U)的个数。注意:字母不分大小写。例如,输入THIs is a boot,则应输出是1 0 2 2 0。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序:

include <conio.h>

include <stdio.h>

/*************found**************/

fun(char *s, int num[5])

{ int k, i=5;

for(k=0;k<i;k++)

/*************found**************/

num [i]=0;

for{;*s;s++)

{ i=-l;

/*************found**************/

switch(s)

{ case 'a': case 'A':{i=0;break;}

case 'e': case 'E':{i=1;break;}

case 'i': case 'I':{i=2;break;}

case 'o': case 'O':{i=3;break;}

case 'u': case 'U':{i=4;break;}

}

if(i>=0)

num[i]++;

}

}

main ( )

{ char s1[81]; int num1[5], i;

clrscr ();

printf("\nPlease enter a string: ");

gets (s1);

fun{s1, num1);

for(i=0;i<5;i++) printf("%d",num1[i]);

printf ("\n");

}


正确答案:(1)错误: fun(char *s int num[5]) 正确: void fun(char *s int hum[5]) (2) 错误: num[i]=0; 正确: num[k]=0; (3) 错误: switch(s) 正确: switch(*s)
(1)错误: fun(char *s, int num[5]) 正确: void fun(char *s, int hum[5]) (2) 错误: num[i]=0; 正确: num[k]=0; (3) 错误: switch(s) 正确: switch(*s) 解析:switch语句说明:
(1)switch后的表达式,可以是整型或字符型,也可以是枚举类型的。在新的ANSIC标准中允许表达式的类型为任何类型。
(2)每个case后的常量表达式只能是常量组成的表达式,当switch后的表达式的值与某一个常量表达式的值一致时,程序就转到此case后的语句开始执行。如果没有一个常量表达式的值与swish后的值一致,就执行default后的语句。
(3)各个case后的常量表达式的值必须互不相同,不然的话程序就不知该跳到何处开始执行。
(4)各个case的次序不影响执行结果,一般情况下,尽量使用出现机率大的case放在前面(为什么,等学到《数据结构》就知道了)。
(5)在执行完一个case后面的语句后,程序流程转到下一个case后的语句开始执行。千万不要理解成行完一个case后程序就转到switch后的语句去执行了。
在本例中,其他错误都比较简单,而且我们在前面已经介绍过了。

第2题:

使用VC6打开考生文件夹下的工程test37_1,此工程包含一个源程序文件test37_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为:

0149 16 25 36 49 64 81

源程序文件test37_1.cpp清单如下:

include<iostream.h>

template <class T, int N = 100> class Vector

{

T vec[N];

public:

void set(int pos, T val);

T get(iht pos);

/***************** found *****************/

}

template <class T, int N> void Vector<T, N>::set(int pos, T val)

{

vec[pos] = val;

}

/***************** found *****************/

template <class T, int N> Vector<T, N>::get(int pos)

{

return vec[pos];

}

int main ()

{

Vector<double, 10> v;

int i = 0;

double d = 0.0;

for (i = 0; i < 10; i++)

v.set(i, double(i * i));

for (i = 0; i < 10; i++)

cout<<v.get(i)<<" ";

cout<<end1;

/***************** found *****************/

}


正确答案:(1) 错误:} 正确:}; (2) 错误:templateclass Tint N>VectorTN>::get(int pos) 正确:templateclass Tint N>T VectorTN>::get(int pos) (3) 错误:缺少返回值 正确:加入 return 0;
(1) 错误:} 正确:}; (2) 错误:templateclass T,int N>VectorT,N>::get(int pos) 正确:templateclass T,int N>T VectorT,N>::get(int pos) (3) 错误:缺少返回值 正确:加入 return 0; 解析:(1)主要考查考生对于类定义的理解,即使使用了类模板,在类定义的结尾仍然需要使用分号,这是C++的规定;
(2)主要考查考生是否会掌握了模板类的定义,template是关键字,在0中间是类型的定义,题目中Vector是一个类的名称,前面应该有该模板的名称,即T,这样才是完整的定义;
(3)主要考查考生对于函数返回值的掌握,任何返回值类型不为int型的函数最后都必须使用returen语句返回对应类型的值,就算是main函数也不例外。

第3题:

下列给定程序中,函数fun()的功能是:用冒泡法对6个字符串按由小到大的顺序进行排序。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.

试题程序:

include <conio.h>

include <stdio.h>

define MAXLINE 20

/*************found**************/

fun(char *pstr[6])

{int i, j;

char *p;

for(i=0;i<5;i++)

{for(j=i+l;j<6;j++)

/*************found**************/

{ if(strcmp(*(pstr+i),pstr+j)>0)

{

p=*(pstr+i);

/*************found**************/

* (pstr+i) -pstr+j;

* (pstr+j)=p;

}

}

}

}

main ( )

{ int i;

char *pstr[6],str[6][MAXLINE];

clrscr();

for(i=0;i<6;i++) pstr[i]=str[i];

printf("\nEnter 6 string(1 string at each

line):\n ");

for(i=0;i<6;i++) scanf("%s",pstr[i]);

fun(pstr);

printf("The strings after sorting:\n ");

for(i=0;i<6;i++) printf("%s\n ",pstr[i]);

}


正确答案:(1)错误: fun(char *pstr[6]) 正确: void fun(char *pstr[6]) (2)错误: if(strcmp(*(pstr+i)pstr+j)>0 正确: if(strcmp(*(pstr+i)*(pstr+j))>0 (3)错误: *(pstr+i)=pstr+j; 正确: *(pstr+i)=*(pstr+j);
(1)错误: fun(char *pstr[6]) 正确: void fun(char *pstr[6]) (2)错误: if(strcmp(*(pstr+i),pstr+j)>0 正确: if(strcmp(*(pstr+i),*(pstr+j))>0 (3)错误: *(pstr+i)=pstr+j; 正确: *(pstr+i)=*(pstr+j); 解析:冒泡法对字符串排序的方法是将相邻两个字符比较,将小的调到前面。令x等于字符串的第i位字符,若该字符的前一位字符大于x,则将该字符与x互换位置。从字符山中的第2位字符到字符串的最后一们字符重复以上过秆,即可完成排序。可用循环语句实现。

第4题:

I′ll never forget the day__________I became a doctor.

A.that
B.which
C.where
D.when

答案:D
解析:

第5题:

The earthquake broke out on a day _______ my father left for America, a day _______I’ll never forget.

A.that; when
B.when; when
C.that; which
D.when; that

答案:D
解析:
本题考查定语从句

D选项,第一个空先行词为day,空格在从句作时间状语,故选when引导后面的定语从句;第二个空先行词为day,空格在从句中作forget的宾语,故用that引导定语从句。综上,D选项正确

A选项,与题意不符,故排除。

B选项,与题意不符,故排除。

C选项,与题意不符,故排除。

故正确答案为D项。

第6题:

I’d like to know what time we can get the container ()it is in the port.

A、where

B、why

C、when


参考答案:C

第7题:

给定程序中,函数proc的功能是:使数组中的元素的值缩小5倍。 请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: include<stdlib.h> include<stdio.h> include<eonio.h> float m[10]; //****found**** int proc(void) { int j; printf("In subfunc after calling\n"); for(j=0;j<10;j++) { //****found**** printf("%f",m[j]%5); } } void main { int i; printf("In main before calling\n"); for(i=0;i<10;i++) { m[i]=i+20; printf("%f",m[i]); } proc; printf("\nln main after calling\n"); for(i=0;i<10;i++) printf("%f",m[i]/5); }


正确答案:
(1)错误:int proc(void)
正确:void proc(void)
(2)错误:printf("%f",m[j]%5);
正确:pfintf("%f",m[j]/5);
【解析】由主函数中的函数调用可知,函数proe没有返回值。因此“int proc(void)”应改为“void proc(void)”。题目中要求使数组中元素的值缩小到l/5,而不是对5取余。因此,“printf("%f",m[j]%5);”应改为“printf(”%f”,mEjl/5);”。

第8题:

Susan: When's the meeting?

Harry: I'm driving into London tomorrow morning. The meeting (60) .


正确答案:D

第9题:

The earthquake broke out on a day______ my father left for America, a day _______ I’ll never forget.

A.that; when
B.when; when
C.that: which
D.when; that

答案:D
解析:
本题考查定语从句
D选项,第一个空先行词为day,空格在从句中时间状语,故选when引导后面的定语从句;第二个空先行词为day,空格在从句中作forget的宾语,故用that引导定语从句。综上,D选项正确。
A选项,第一个空先行词为时间状语day, that不适合,故排除。
B选项,第二个空先行词为宾语day,when不适合,故排除。
C选项,先行词为day, that不适合,故排除。
故正确答案为 D项。

第10题:

20、以下程序的输出结果是()? letter = ['A','B', 'C', 'D', 'D'] for i in letter: if i == 'D': letter.remove(i) print(letter)

A.['A','B', 'C', 'D']

B.['A','B', 'C', 'D','D']

C.['A','B', 'C', 'D','D','D']

D.['A','B', 'C']


B 本题的考查点是不同格式的数据输出。prinff函数对不同类型的数据用不同的格式字符,”%d”是以带符号的十进制形式输出整数(正数不输出符号);”%O”以八进制无符号形式输出整数(不包括前导符0);”%x”以十六进制无符号形式输出整数(不包括前导符0x)。