c - 如何在 PlantUML 事件图中使用 C 中的 "continue"语句表示循环

标签 c uml activity-diagram plantuml

我需要使用 PlantUML 将下面的 C 代码转换为事件图。

从下面的代码中实现“继续”语句的好解决方案是什么?

    void function_1(){
    int a = 0;
    int b =0;
      for (int i; i < 8; i++)
      {
        if (i < 2)
        {
           continue;
        }
        if (i > 4)
        {
            a = 1;
        }           
        else
        {
           b = 2;
        }
      }
    }

最佳答案

我不懂 C,但在我看来,在 PlantUML 中表示逻辑的一种方法如下:

start
while (i < 8 ?)
  if (i > 4 ?) then (yes)
      :a = 1;
  else (no)
      if (i >= 2 ?) then (yes)
      :b = 2;
      else (no)
      endif
  endif
 endwhile (no)
:Carry out the next task;
end

“执行下一个任务”任务是一个占位符。它应该替换为您的应用程序下一步应该执行的操作。

产生 the following diagramme :

enter image description here

关于c - 如何在 PlantUML 事件图中使用 C 中的 "continue"语句表示循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58637166/

相关文章:

UML 类图构造

java - 任何免费可靠的 Eclipse Activity 图工具

c - 两个 MPI_Allreduce() 函数不起作用,给出 NULL Communicator 错误

c - 将负浮点值转换为无符号整数的行为是什么?

c - 通过剥离未使用的代码来解决 undefined reference

android - cpu-features.h 没有这样的文件或目录 webrtc Android 构建

java - 从 umbrello 中的 java 代码自动创建类图?

uml - 如何为 Draw.io Database 3 软件图表类型表表示中的字段添加数据类型?

uml - 示例 UML 事件图

uml - 如何表示一个复杂的用例,其中主要流程的每个步骤都可以有多个场景(替代或错误路径)?