Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
17
Task/Arithmetic-Integer/Bracmat/arithmetic-integer.bracmat
Normal file
17
Task/Arithmetic-Integer/Bracmat/arithmetic-integer.bracmat
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
( enter
|
||||
= put$"Enter two integer numbers, separated by space:"
|
||||
& get':(~/#?k_~/#?m|quit:?k)
|
||||
| out
|
||||
$ "You must enter two integer numbers! Enter \"quit\" if you don't know how to do that."
|
||||
& !enter
|
||||
)
|
||||
& !enter
|
||||
& !k:~quit
|
||||
& out$("You entered" !k and !m ". Now look:")
|
||||
& out$("Sum:" !k+!m)
|
||||
& out$("Difference:" !k+-1*!m)
|
||||
& out$("Product:" !k*!m)
|
||||
& out$("Integer division:" div$(!k.!m))
|
||||
& out$("Remainder:" mod$(!k.!m))
|
||||
& out$("Exponentiation:" !k^!m)
|
||||
& done;
|
||||
11
Task/Arithmetic-Integer/Clipper/arithmetic-integer.clipper
Normal file
11
Task/Arithmetic-Integer/Clipper/arithmetic-integer.clipper
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Function( a, b )
|
||||
? "a+b", a + b
|
||||
? "a-b", a - b
|
||||
? "a*b", a * b
|
||||
// The quotient isn't integer, so we use the Int() function, which truncates it downward.
|
||||
? "a/b", Int( a / b )
|
||||
// Remainder:
|
||||
? "a%b", a % b
|
||||
// Exponentiation is also a base arithmetic operation
|
||||
? "a**b", a ** b
|
||||
Return Nil
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
#define system.
|
||||
#define extensions'io.
|
||||
#define extensions'math.
|
||||
#define extensions.
|
||||
|
||||
// --- Program ---
|
||||
|
||||
|
|
@ -13,5 +12,5 @@
|
|||
consoleEx << a << " - " << b << " = " << a - b << "%n".
|
||||
consoleEx << a << " * " << b << " = " << a * b << "%n".
|
||||
consoleEx << a << " / " << b << " = " << a / b << "%n". // truncates towards 0
|
||||
consoleEx << a << " %% " << b << " = " << (modulus:a:b) << "%n". // matches sign of first operand
|
||||
consoleEx << a << " %% " << b << " = " << (a~mathOp mod:b) << "%n". // matches sign of first operand
|
||||
].
|
||||
|
|
|
|||
22
Task/Arithmetic-Integer/Nimrod/arithmetic-integer.nimrod
Normal file
22
Task/Arithmetic-Integer/Nimrod/arithmetic-integer.nimrod
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import parseopt,strutils
|
||||
|
||||
var
|
||||
opt: TOptParser = initOptParser()
|
||||
str = opt.cmdLineRest.split
|
||||
a: int = 0
|
||||
b: int = 0
|
||||
|
||||
try:
|
||||
a = parseInt(str[0])
|
||||
b = parseInt(str[1])
|
||||
except EinvalidValue:
|
||||
quit("Invalid params. Two integers are expected.")
|
||||
|
||||
|
||||
echo ("a : " & $a)
|
||||
echo ("b : " & $b)
|
||||
echo ("a + b : " & $(a+b))
|
||||
echo ("a - b : " & $(a-b))
|
||||
echo ("a * b : " & $(a*b))
|
||||
echo ("a div b: " & $(a div b))
|
||||
echo ("a mod b: " & $(a mod b))
|
||||
17
Task/Arithmetic-Integer/VBA/arithmetic-integer.vba
Normal file
17
Task/Arithmetic-Integer/VBA/arithmetic-integer.vba
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
'Arithmetic - Integer
|
||||
Sub RosettaArithmeticInt()
|
||||
Dim opr As Variant, a As Integer, b As Integer
|
||||
On Error Resume Next
|
||||
|
||||
a = CInt(InputBox("Enter first integer", "XLSM | Arithmetic"))
|
||||
b = CInt(InputBox("Enter second integer", "XLSM | Arithmetic"))
|
||||
|
||||
Debug.Print "a ="; a, "b="; b, vbCr
|
||||
For Each opr In Split("+ - * / \ mod ^", " ")
|
||||
Select Case opr
|
||||
Case "mod": Debug.Print "a mod b", a; "mod"; b, a Mod b
|
||||
Case "\": Debug.Print "a \ b", a; "\"; b, a \ b
|
||||
Case Else: Debug.Print "a "; opr; " b", a; opr; b, Evaluate(a & opr & b)
|
||||
End Select
|
||||
Next opr
|
||||
End Sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue