c++ test!

CountFloyd 2003-10-21 09:50:27
If you have "int main(int argc, char* argv[])" and invoke your program this way:
prog.exe a.out -i 2 -g -x 3 4
What will be the value of argc?

a) 0
b) a.out
c) 2
d) 3
e) 7
f) Other
g) I don't know

If we have:

int f(int x)
{
if(x>2)
return x + f(--x);
else
return 0;
}
What will be the resulf of: cout << f(5);
a) Program will freeze
b) 0
c) 6
d) 10
e) 12
f) Other
g) I don't know

If we have this code:

char arr[8];
cin >> arr;

And this text is entered: "Hello World", what there will be in "arr"?
a) Hello World
b) Hello Wo
c) Hello W
d) Hello
e) Other
f) I don't know

What will happen if we have this code:

char a[3] = {'d','w','\0'};
char b[3];
b = a;

a) "b" will be the same as "a"
b) "b" will be unchanged
c) Compiler error
d) Other
e) I don't know

...全文
31 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
CountFloyd 2003-10-22
  • 打赏
  • 举报
回复
第一题 answer : f 谁能解释一下?
第二题 jEditor(jEditor)答对了。4+3+2=9
第三题 d
第四题 c


全对的加分!
shery1 2003-10-21
  • 打赏
  • 举报
回复
f(9)
f(9)
d
c(left operand must be l-value)
vc 6.0 下测试
aron13 2003-10-21
  • 打赏
  • 举报
回复
argc 是参数个数+1;argv[]就存放着这些参数。
argc==7;
而2题是一个递归。功能是:当参数〈2时 参数+(参数-1)。所以为:12
3题错误。
4题:b将和a共享一个内存地址。所以b的内容是a的内容,并且a改变时,b改变。
aflyinghorse 2003-10-21
  • 打赏
  • 举报
回复
e
f
d
c
daiwei1852(倦鸟)正确
tibetan 2003-10-21
  • 打赏
  • 举报
回复
e) 12
d) Hello cin breaks when meets a blankkey.
c) Compiler error The name of array is a constant.
elitel 2003-10-21
  • 打赏
  • 举报
回复
third:
b
arfi 2003-10-21
  • 打赏
  • 举报
回复
f f d c
daiwei1852 2003-10-21
  • 打赏
  • 举报
回复
e
f
d
c
jEditor 2003-10-21
  • 打赏
  • 举报
回复
楼上兄台第二题错了.
优先于f(--x),结果:4+3+2=9!!!!!!
jEditor 2003-10-21
  • 打赏
  • 举报
回复

f
d
c
aflyinghorse 2003-10-21
  • 打赏
  • 举报
回复
e
e 5+4+3+0=12
d
c
oyd 2003-10-21
  • 打赏
  • 举报
回复
第2题是f) 8
argv[0] prog.exe
argv[1] a.out
...
argv[7] 4
所以argc为8很明显的

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧