latex中algorithm2e包的用法示例收藏

时间:2022-09-14 19:26:45

 1.首先添加如下内容:
/usepackage[linesnumbered,boxed]{algorithm2e}
2.然后正文中添加如下示例:
/begin{algorithm}
/caption{identifyRowContext}
/KwIn{$r_i$ , $Backgrd(T_i)$=${T_1,T_2,/ldots,T_n}$ and similarity threshold $/theta_r$}
/KwOut{$con(r_i)$}
$con(r_i)= /Phi$/;
/For{$j=1;j /le n;j /ne i$}
{
 float $maxSim=0$/;
 $r^{maxSim}=null$/;
 
 /While{not end of $T_j$}
 {
     compute Jaro($r_i,r_m$)($r_m /in T_j$)/;
     /If{$(Jaro(r_i,r_m) /ge /theta _r) /wedge ((Jaro(r_i,r_m) /ge r^{maxSim}) $}
      {
           replace $r^maxSim$ with $r_m$/;

      }   


 }
$con(r_i)=con(r_i) /cup {r^{maxSim}}$/;

}
return $con(r_i)$/;
/end{algorithm}
3.效果运行可知。