单选题 程序员
题号 #702255

The construct
cobegin
Statement1;
Statement2;
coend
means Statement1 and Statement2 are to be executed in parallel.The only two atomic actions in this construct are loading the value of a variable and storing into a variable.For the program segment
x=0;y=0;
cobegin
{x=1;y+=x;}
{y=2;x+=3;}
coend
Which of the following indicate(s)possible values for the variables when the segment finishes execution?   .
Ⅰ.x=1,y=2
Ⅱ.x=1,y=3
Ⅲ.x=4,y=6

进入在线模考

参考答案

D

答案解析

译文:结构
Cobegin
Statement1;
Statement2;
Coend
的含义是语句1和语句2并行执行。结构中的两个原子操作是加载一个变量的值和存储一个变量的值。
【程序段】
x=0;y=0;
cobegin
{x=1;y+=x;}
{y=2;x+=3;}
coend
执行后,变量的值可能是哪个?
先执行第二句再执行第一句,结果是II,否则结果是Ⅲ。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考