我没有成功使用do-while或while循环来完成以下图表:
这里,A、B和C都是函数。如何为上述图表编写伪代码?
编辑:这是我在练习C++编程时遇到的问题。如果没有“B循环”(或“A循环”),我可以将其编写为以下形式:
Start
Input x;
while(x!=2)
{
A(); Input x;
}
C();
End
然而,当"B循环"出现时,我不知道如何将其包含在内。
我没有成功使用do-while或while循环来完成以下图表:
这里,A、B和C都是函数。如何为上述图表编写伪代码?
编辑:这是我在练习C++编程时遇到的问题。如果没有“B循环”(或“A循环”),我可以将其编写为以下形式:
Start
Input x;
while(x!=2)
{
A(); Input x;
}
C();
End
Start;
Input x;
while(x!=2){
if (x!=1){
A();
} else{
B()
}
Input x;
}
C();
End
但是要注意你使用的语言,我建议在数据采集之间添加休眠模式(就在输入x之前)。
Start;
Do
{
Input x;
if (x equals 1)
{
B();
}
elseif(x not equal to 2)
{
A();
}
} While (x not equal to 2);
C();
End;
If any input
if input is not 1 and not 2
return a and do more input (? dont get the diagram here ;p)
if input is 1
return b and more input (??)
else if not above
return c and end program
A
,B
,C
写成A()
,B()
,C()
,因为它们都是函数。 - user758077