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");
}
第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 *****************/
}
第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]);
}
第4题:
第5题:
第6题:
A、where
B、why
C、when
第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); }
第8题:
Susan: When's the meeting?
Harry: I'm driving into London tomorrow morning. The meeting (60) .
第9题:
第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']