呈现学校计算算法的最佳解决方案

呈现学校计算算法的最佳解决方案

我需要排版一些计算类算法例如:

Repeat
 Accept Roll_Number
If (the Roll Number has already been added to the absent list) then 
 Prompt”You have already added the roll number to the absent list”
Else
         Continue with the adding process
End if
         Connect to the Student’s table of Malpi’s database
Search for the match of Roll_Number
If (the match is found) Then
         Display Student’s firstname,middlename,lastname,guardianname,contactnumber
Else
         Don’t Display Anything
End If
Until (all the absent students have been added to the absent list)
Open the absent file where the records are to be added
Repeat
         If (the student has already been added to the file for that day) Then
                  Prompt” The student has already been added to the file”
         Else
                  Continue
         End if
Until (All the Roll_Number in the list have been checked)
Get the record number of the last record in the absent file
Open the absent file where the records are to be added
Repeat
        Add 1 to the record number
        Save the student’s absent details to the file
Until (the records of all the students are saved in the absent file)

在 XeTeX 中表示此内容的最佳方法是什么?我尝试使用 \verbatim 包,但它似乎破坏了边距?有什么好方法可以呈现此内容吗?

答案1

为什么不使用“普通”文本代替\verbatim?我认为列表(enumerate)会很合适。我认为\verbatim在这里没有任何优势,我也不一定在这里选择排版字体:它是一种算法, 不是源代码

或者,你可以尝试以下方法之一伪代码排版包

就我个人而言,我更喜欢流程图显示算法,但我不知道在 LaTeX 中排版它们的好方法(当然,除了使用 TikZ 或 PSTtricks)。

相关内容