一些很bt的C++笔试题目,求答案

futuredreams 2005-12-10 12:46:12
请看最后的3套题目,全部是关于指针野指针的,求正确答案:
http://dfsc.cn/mambo/forum/index.php?topic=35.0
例子:
3. Consider the following program:
main()
{
int a[][3] = { 1,2,3 ,4,5,6};
int (*ptr)[3] =a;

printf("%d %d " ,(*ptr)[1], (*ptr)[2] );

++ptr;
printf("%d %d" ,(*ptr)[1], (*ptr)[2] );
}
The output for this program is:

(a) 2 3 5 6
(b) 2 3 4 5
(c) 4 5 0 0
(d) None of the above

12. Object modules generated by assemblers that contain unresolved external references are resolved for two or more object modules by a/an

(A) linker
(B) loader
(C) operating system
(D) debugger
(E) compiler

16. In a multiprogramming system, a set of processes is deadlocked if each process in the set is waiting for an event to occur that can be initiated only by another process in the set. Which of the following is NOT one of the four conditions that are necessary for deadlock to occur?

(A) mutual exclusion
(B) partial assignment of resources
(C) nonpreemption
(D) process suspension
(E) circular wait
...全文
618 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
futuredreams 2005-12-14
  • 打赏
  • 举报
回复
楼上给的是哪个题目的答案?谢谢!
futuredreams 2005-12-13
  • 打赏
  • 举报
回复
请给出下面这段代码执行后的输出结果:

int main()
{
int i = 0;
char outstring[10];
sprintf(outstring, "%d %d %d %d", i, i - 1, ++i,i++);
printf("i = %d\r\n output string = %s", i, outstring);
}

http://dfsc.cn/mambo/forum/index.php?topic=35.0

给出笔试答案就结,谢谢各位了。急用!!!
dbjk 2005-12-13
  • 打赏
  • 举报
回复
2
1 0 1 0
进栈出栈
futuredreams 2005-12-11
  • 打赏
  • 举报
回复
谢谢众位大大回复,求所有题目的解答,上面的只是3个例子(可能相对不算bt的)因为题目太多了,没有贴过来,在上面那个联接里面,谢谢。
chenhao518530 2005-12-11
  • 打赏
  • 举报
回复
同意上面的,问题不变态。很简单。
greenteanet 2005-12-11
  • 打赏
  • 举报
回复
3.A首先(*ptr)指向数组首地址,即(*ptr)[0]指向数字1, (*ptr)[1]指向2,(*ptr)[2]指向3。然后,++ptr;,使ptr指向数组的第二行,即指向4,同理,这次(*ptr)[1]指向5,(*ptr)[2]指向6。
12.A
13.D
guyanhun 2005-12-10
  • 打赏
  • 举报
回复
12 .
A
guyanhun 2005-12-10
  • 打赏
  • 举报
回复
3 .

A
iamcaicainiao 2005-12-10
  • 打赏
  • 举报
回复
3A, ,首先(*ptr)指向数组首地址,即(*ptr)[0]指向数字1, 所以(*ptr)[1]指向2
(*ptr)[2]指向3。然后,++ptr;,使ptr指向数组的第二行,即指向4,同理,这次(*ptr)[1]指向5,(*ptr)[2]指向6。
12A使用外部资源,由连接器来完成
16楼上的楼上解释很清楚了。
yuanchuang 2005-12-10
  • 打赏
  • 举报
回复
不变态啊
sankt 2005-12-10
  • 打赏
  • 举报
回复
3 A
12 A
16 D
kilinux 2005-12-10
  • 打赏
  • 举报
回复
Coffman, Elphick和Shoshani于1971年总结了产生死锁的四个必要条件:
互斥条件(mutual exclusion):一个资源一次只能由一个进程使用,如果有其它进程申请使用该资源,申请进程必须等待直到所申请的资源被释放。
部分分配条件(hold and wait);一个进程已占有一定资源后,执行期间又再申请其它资源。
不可抢占条件(no preemption):一个资源仅能由一个占有它的进程来释放,而不能被其它进程抢占使用。
循环等待条件(circular wait):在系统中存在一个由若干进程申请使用资源而形成的循环等待链,其中每一个进程占有若干资源,同时由又在等待下一个进程所占有的资源。
要防止死锁问题,其根本的办法就是要使得上述四个条件之一不存在。
所以第16题答案是D。

15,447

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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