Perl 128114个字符
($a,$b)=split;$_=" "x7;until($b<2){$==$a/$b;($a,$b)=($b,$a%$b);$_.="1\e[B\e[7D$= + ---------\e[B\e[4D"}$_.="$a\n"
但是,由于要使用控制台,因此必须在运行之前按顺序清除控制台:
clear
perl -pe '($a,$b)=split;$_=" "x7;until($b<2){$==$a/$b;($a,$b)=($b,$a%$b);$_.=
"1\e[B\e[7D$= + ---------\e[B\e[4D"}$_.="$a\n"' <<<$'5 7 \n189 53 \n9 16 \n89 150 '
输出:
1
0 + ---------
1
1 + ---------
1
2 + ---------
2
1
3 + ---------
1
1 + ---------
1
1 + ---------
1
3 + ---------
1
3 + ---------
2
1
0 + ---------
1
1 + ---------
1
1 + ---------
1
3 + ---------
2
1
0 + ---------
1
1 + ---------
1
1 + ---------
1
2 + ---------
1
5 + ---------
1
1 + ---------
1
1 + ---------
2
第一篇文章:128个字符
($a,$b)=split;$c=7;while($b>1){$==$a/$b;($a,$b)=($b,$a%$b);printf"%s1\n%${c}d + %s\n"," "x($c+=5),$=,"-"x9}printf" %${c}d\n",$=
分裂为cut'n贴:
perl -ne '($a,$b)=split;$c=7;while($b>1){$==$a/$b;($a,$b)=($b,$a%$b);printf
"%s1\n%${c}d + %s\n"," "x($c+=5),$=,"-"x9}printf" %${c}d\n",$a' \
<<<$'5 7 \n189 53 \n9 16 \n89 150 '
将呈现:
1
0 + ---------
1
1 + ---------
1
2 + ---------
2
1
3 + ---------
1
1 + ---------
1
1 + ---------
1
3 + ---------
1
3 + ---------
2
1
0 + ---------
1
1 + ---------
1
1 + ---------
1
3 + ---------
2
1
0 + ---------
1
1 + ---------
1
1 + ---------
1
2 + ---------
1
5 + ---------
1
1 + ---------
1
1 + ---------
2
同样使用LaTeX:
perl -ne 'END{print "\\end{document}\n";};BEGIN{print "\\documentclass{article}\\pagestyle".
"{empty}\\begin{document}\n";};($a,$b)=split;$c="";print "\$ $a / $b = ";while($b>1){$==$a
/$b;($a,$b)=($b,$a%$b);printf"%s + \\frac{1}{",$=;$c.="}";}printf"%d%s\$\n\n",$a,$c' \
<<<$'5 7 \n189 53 \n9 16 \n89 150 ' >fracts.tex
pslatex fracts.tex
dvips -f -ta4 <fracts.dvi |
gs -sDEVICE=pnmraw -r600 -sOutputFile=- -q -dNOPAUSE - -c quit |
pnmcrop |
pnmscale .3 |
pnmtopng >fracts.png
0 + 89 / 250
为最后一个做?