From de84782edc12c5abe3277d0f162e28fa0033c7d7 Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 20 Jan 2010 13:15:11 +0300 Subject: Maximum of 2 numbers --- max2.bf | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 max2.bf diff --git a/max2.bf b/max2.bf new file mode 100644 index 0000000..f2665d4 --- /dev/null +++ b/max2.bf @@ -0,0 +1,36 @@ +# Show the maximum number + +# == Preparations == + +# input the 1st number into the 1st cell +, # |a|0|0|0|0|0| + +# copy 1st cell into the 2nd and the 5th cells +[->+>>>+<<<<] # |0|a|0|0|a|0| + + +# input the 2nd number into the 1st cell +, # |b|a|0|0|a|0| + +# copy 1st cell into the 3nd and the 6th cells +[->>+>>>+<<<<<] # |0|a|b|0|a|b| + +> # move to the 2nd cell + + + +# == Main loop == + +# decrement both 2nd and 3rd cells by 1, +# the final position depends on which number is bigger +[[->]<<] + + +# == Result == +# go to the answer +>>>> + +# show the answer +. + + -- cgit v1.2.3