The score: 14.00 / 14.00 , this test submission time: 2020-03-08 , if you think this test result is not satisfactory, you can chooseDo it again.
The following program fragment which is right?
-
A.
int n = 4;
int & r = n * 5;
-
B.
int n = 6;
const int & r = n;
r = 7;
-
C.
int n = 8;
const int & r1 = n;
int & r2 = r1;
-
D.
int n = 8;
int & r1 = n;
const int r2 = r1;
What output is the following program fragment?
int a = 1,b = 2;
int & r = a;
r = b;
r = 7;
cout << a << endl;
-
A.
1
-
B.
2
-
C.
7
-
D.
8
Which of the following statements is correct?
-
A.
Often cited reference variable which can not be modified
-
B.
Can not be constant pointer, which points to modify variables
-
C.
Once a constant pointer pointing to a variable, you can not point to other variables
-
D.
1+1 = 3
The expression "new int" return value type is:
-
A.
int
-
B.
int *
-
C.
int &
-
D.
void
The following subparagraph program, which is correct:
-
A.
char * p = new char[10];
p[0] = 'K';
delete [] p;
-
B.
int *p = new int[25];
p[10] = 100;
delete p
-
C.
char * p = new int;
p = 'a';
delete p;
-
D.
int * p = new char[20];
The following statement is correct:
-
A.
The number of parameters of a plurality of overloaded functions must be different.
-
B.
Two functions, identical parameter table, different types of return value, which relation is overloaded.
-
C.
When you call a second and third parameters have default values have a function, you can not write the second argument and write the third argument.
-
D.
The purpose is to increase the inline function of running speed.
-
Fill in the blank (2 points) simply swap by code is (please refer to the announcement, "Note on programming operations" to complete the programming operation (Please note that programming questions are asked to submit by code, submitted a program on openjudge and later through it It can be downloaded through the code.)
Total time limit: 1000ms Memory Limit: 65536kB
Description: fill in the blank, so that the program output is: 5,3
12345678910111213141516171819202122232425#include <iostream>
using
namespace
std;
class
A
{
public
:
int
x;
int
getX() {
return
x; }
};
void
swap(
// 在此处补充你的代码
)
{
int
tmp = a.x;
a.x = b.x;
b.x = tmp;
}
int
main()
{
A a,b;
a.x = 3;
b.x = 5;
swap(a,b);
cout << a.getX() <<
","
<< b.getX();
return
0;
}
Input None Output 5,3
answer:
8 Fill in the blanks (2 points) little difficult swapFill in the blank, so that the program output is: 5,3
1234567891011121314151617181920#include <iostream>
using
namespace
std;
void
swap(
// 在此处补充你的代码
)
{
int
* tmp = a;
a = b;
b = tmp;
}
int
main()
{
int
a = 3,b = 5;
int
* pa = & a;
int
* pb = & b;
swap(pa,pb);
cout << *pa <<
","
<< * pb;
return
0;
}
答案:
9 填空(2分) 好怪异的返回值填空,使得程序输出指定结果1234567891011121314#include <iostream>
using
namespace
std;
// 在此处补充你的代码
getElement(
int
* a,
int
i)
{
return
a[i];
}
int
main()
{
int
a[] = {1,2,3};
getElement(a,1) = 10;
cout << a[1] ;
return
0;
}
输入 无 输出 10
答案:
10 填空(2分) 神秘的数组初始化12345678910111213141516#include <iostream>
using
namespace
std;
int
main()
{
int
* a[] = {
// 在此处补充你的代码
};
*a[2] = 123;
a[3][5] = 456;
if
(! a[0] ) {
cout << * a[2] <<
","
<< a[3][5];
}
return
0;
}
输入 无 输出 123,456
答案: