Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Arithmetic-Integer/Nim/arithmetic-integer.nim
Normal file
23
Task/Arithmetic-Integer/Nim/arithmetic-integer.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import parseopt, strutils
|
||||
|
||||
var
|
||||
opt: OptParser = initOptParser()
|
||||
str = opt.cmdLineRest.split
|
||||
a: int = 0
|
||||
b: int = 0
|
||||
|
||||
try:
|
||||
a = parseInt(str[0])
|
||||
b = parseInt(str[1])
|
||||
except ValueError:
|
||||
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)) # div rounds towards zero
|
||||
echo("a mod b: " & $(a mod b)) # sign(a mod b)==sign(a) if sign(a)!=sign(b)
|
||||
echo("a ^ b : " & $(a ^ b))
|
||||
Loading…
Add table
Add a link
Reference in a new issue