●The constructcobeginStatement1;Statement2;coendmeans Statement1 and Statement2
●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? (74) .
Ⅰ.x=1,y=2
Ⅱ.x=1,y=3
Ⅲ.x=4,y=6
(74) A.Ⅰ
B.Ⅰ,Ⅱ
C.Ⅰ,Ⅲ
D.Ⅱ and Ⅲ
正确答案:D【解析】译文:结构CobeginStatement1;Statement2;Coend的含义是语句1和语句2并行执行。结构中的两个原子操作是加载一个变量的值和存储一个变量的值。【程序段】x=0;y=0;cobegin{x=1;y+=x;}{y=2;x+=3;}coend执行后,变量的值可能是哪个?先执行第二句再执行第一句,结果是II,否则结果是III。
词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。
