爱迪国际c++章节测试-类型综合

*
1.
.单选题
把 64 位非零浮点数强制转换成32 位浮点数后,不可能( ).
A. 大于原数
B. 小于原数
C. 等于原数
D. 与原数符号相反
*
2.
单选题
要求以下程序的功能是计算s=1+1/2+1/3+...+1/10
#include <iostream>
using namespace std;
int main()
{
int n;
float s;
s = 1.0;
for(n = 10; n > 1; n--)
s = s + 1 / n;
cout << s << endl;
return 0;
}
程序运行后输出结果错误,导致错误结果的程序行是( )。
A. s = 1.0;
B. for(n = 10; n > 1; n--)
C. s = s + 1 / n;
D. cout << s << endl;
*
3.
填空题(8分)
#include <iostream>
using namespace std;
struct point
{
int x;
int y;
};

int main()
{
int a, b, c;
struct EX
{
int a;
int b;
point c;
} e;

e.a = 1;
e.b = 2;
e.c.x= e.a + e.b;
e.c.y= e.a * e.b;
cout << e.c.x << ',' << e.c.y << endl;
return(0);
}

阅读程序写结果:

输出:___________

*
4.
4.填空题(8分)

#include <iostream>
#include <string>
using namespace std;

void fun( char *a, char *b )
{
a = b;
(*a)++;
}

int main()
{
char c1, c2, *p1, *p2;
c1 = 'A';
c2 = 'a';
p1 = &c1;
p2 = &c2;
fun( p1, p2 );
cout << c1 << c2 << endl;
return(0);
}

输出:__________

阅读程序写结果:

*
5.
填空题
#include <iostream>
using namespace std;

int main(){
int a[6] = {1, 2, 3, 4, 5, 6};
int pi = 0;
int pj = 5;
int t, i;
while (pi < pj)
{
t = a[pi];
a[pi] = a[pj];
a[pj] = t;
pi++;
pj--;
}
for (i = 0; i < 6; i++)
cout << a[i] << ",";
cout << endl;
return 0;
}

阅读程序写结果:

输出:____

问卷星提供技术支持
举报