-3
假設我有一些分支代碼,如下所示。解決此問題所需的算法
if condition 1
code_line 1
code_line 2
more lines...
if condition 2
code_line 3
code_line 4
if condition 7
code_line 13
code_line 14
end if
more lines...
end if
if condition 5
code_line 6
code_line 10
more lines...
end if
else
code_line 7
more lines...
end if
我想要一個方法可以讀取這段代碼,並告訴我所有給定行的前提條件。
實例:
- 對應code_line 4是內部條件2其內部條件1。
- code_line 7 is condition 1。
- 對應code_line 14是內部條件7其內部條件2其內部條件1。
if-else塊可以嵌套無限次數。
編輯了自己的問題,但並沒有真正接近理解它。你到底需要做什麼? – raina77ow
看起來像周圍的上下文,語法上定義 – fork0
如果您搜索codeline 7,不應該輸出'如果條件5'嵌套'條件1'? – gaganbm