CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
12
Task/Arithmetic-Integer/C++/arithmetic-integer.cpp
Normal file
12
Task/Arithmetic-Integer/C++/arithmetic-integer.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a, b;
|
||||
std::cin >> a >> b;
|
||||
std::cout << "a+b = " << a+b << "\n";
|
||||
std::cout << "a-b = " << a-b << "\n";
|
||||
std::cout << "a*b = " << a*b << "\n";
|
||||
std::cout << "a/b = " << a/b << ", remainder " << a%b << "\n";
|
||||
return 0;
|
||||
}
|
||||
36
Task/Arithmetic-Integer/Chef/arithmetic-integer.chef
Normal file
36
Task/Arithmetic-Integer/Chef/arithmetic-integer.chef
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
Number Soup.
|
||||
|
||||
Only reads single values.
|
||||
|
||||
Ingredients.
|
||||
1 g Numbers
|
||||
3 g Water
|
||||
5 g Soup
|
||||
|
||||
Method.
|
||||
Take Numbers from refrigerator.
|
||||
Take Soup from refrigerator.
|
||||
Put Numbers into 1st mixing bowl.
|
||||
Add Soup into the 1st mixing bowl.
|
||||
Pour contents of the 1st mixing bowl into 1st baking dish.
|
||||
Clean 1st mixing bowl.
|
||||
Put Numbers into 1st mixing bowl.
|
||||
Remove Soup from 1st mixing bowl.
|
||||
Pour contents of the 1st mixing bowl into 2nd baking dish.
|
||||
Clean 1st mixing bowl.
|
||||
Put Numbers into 1st mixing bowl.
|
||||
Combine Soup into 1st mixing bowl.
|
||||
Pour contents of the 1st mixing bowl into 3rd baking dish.
|
||||
Clean 1st mixing bowl.
|
||||
Put Numbers into 1st mixing bowl.
|
||||
Divide Soup into 1st mixing bowl.
|
||||
Pour contents of the 1st mixing bowl into 4th baking dish.
|
||||
Clean 1st mixing bowl.
|
||||
Put Water into 1st mixing bowl.
|
||||
Verb the Soup.
|
||||
Combine Numbers into 1st mixing bowl.
|
||||
Verb the Soup until verbed.
|
||||
Pour contents of the 1st mixing bowl into 5th baking dish.
|
||||
Clean 1st mixing bowl.
|
||||
|
||||
Serves 5.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(defun arithmetic (&optional (a (read *query-io*)) (b (read *query-io*)))
|
||||
(mapc
|
||||
(lambda (op)
|
||||
(format t "~a => ~a~%" (list op a b) (funcall (symbol-function op) a b)))
|
||||
'(+ - * mod rem floor ceiling truncate round expt))
|
||||
(values))
|
||||
17
Task/Arithmetic-Integer/D/arithmetic-integer-1.d
Normal file
17
Task/Arithmetic-Integer/D/arithmetic-integer-1.d
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import std.stdio, std.string, std.conv;
|
||||
|
||||
void main() {
|
||||
int a = 10, b = 20;
|
||||
try {
|
||||
a = readln().strip().to!int();
|
||||
b = readln().strip().to!int();
|
||||
} catch (StdioException e) {}
|
||||
writeln("a = ", a, ", b = ", b);
|
||||
|
||||
writeln("a + b = ", a + b);
|
||||
writeln("a - b = ", a - b);
|
||||
writeln("a * b = ", a * b);
|
||||
writeln("a / b = ", a / b);
|
||||
writeln("a % b = ", a % b);
|
||||
writeln("a ^^ b = ", a ^^ b);
|
||||
}
|
||||
13
Task/Arithmetic-Integer/D/arithmetic-integer-2.d
Normal file
13
Task/Arithmetic-Integer/D/arithmetic-integer-2.d
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import std.stdio, std.string, std.conv, std.typetuple;
|
||||
|
||||
void main() {
|
||||
int a = -16, b = 5;
|
||||
try {
|
||||
a = readln().strip().to!int();
|
||||
b = readln().strip().to!int();
|
||||
} catch (StdioException e) {}
|
||||
writeln("a = ", a, ", b = ", b);
|
||||
|
||||
foreach (op; TypeTuple!("+", "-", "*", "/", "%", "^^"))
|
||||
mixin(`writeln("a ` ~ op ~ ` b = ", a` ~ op ~ `b);`);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
var a := StrToInt(ParamStr(0));
|
||||
var b := StrToInt(ParamStr(1));
|
||||
|
||||
PrintLn(Format('%d + %d = %d', [a, b, a + b]));
|
||||
PrintLn(Format('%d - %d = %d', [a, b, a - b]));
|
||||
PrintLn(Format('%d * %d = %d', [a, b, a * b]));
|
||||
PrintLn(Format('%d / %d = %d', [a, b, a div b]));
|
||||
PrintLn(Format('%d mod %d = %d', [a, b, a mod b]));
|
||||
PrintLn(Format('%d ^ %d = %d', [a, b, Trunc(Power(a, b))]));
|
||||
19
Task/Arithmetic-Integer/Delphi/arithmetic-integer.delphi
Normal file
19
Task/Arithmetic-Integer/Delphi/arithmetic-integer.delphi
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
program IntegerArithmetic;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses SysUtils, Math;
|
||||
|
||||
var
|
||||
a, b: Integer;
|
||||
begin
|
||||
a := StrToInt(ParamStr(1));
|
||||
b := StrToInt(ParamStr(2));
|
||||
|
||||
WriteLn(Format('%d + %d = %d', [a, b, a + b]));
|
||||
WriteLn(Format('%d - %d = %d', [a, b, a - b]));
|
||||
WriteLn(Format('%d * %d = %d', [a, b, a * b]));
|
||||
WriteLn(Format('%d / %d = %d', [a, b, a div b])); // rounds towards 0
|
||||
WriteLn(Format('%d %% %d = %d', [a, b, a mod b])); // matches sign of the first operand
|
||||
WriteLn(Format('%d ^ %d = %d', [a, b, Trunc(Power(a, b))]));
|
||||
end.
|
||||
8
Task/Arithmetic-Integer/E/arithmetic-integer.e
Normal file
8
Task/Arithmetic-Integer/E/arithmetic-integer.e
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def arithmetic(a :int, b :int) {
|
||||
return `$\
|
||||
Sum: ${a + b}
|
||||
Difference: ${a - b}
|
||||
Product: ${a * b}
|
||||
Quotient: ${a // b}
|
||||
Remainder: ${a % b}$\n`
|
||||
}
|
||||
15
Task/Arithmetic-Integer/Efene/arithmetic-integer.efene
Normal file
15
Task/Arithmetic-Integer/Efene/arithmetic-integer.efene
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
@public
|
||||
run = fn () {
|
||||
|
||||
First = io.get_line("First number: ")
|
||||
Second = io.get_line("Second number: ")
|
||||
|
||||
A = list_to_integer(lists.delete($\n, First))
|
||||
B = list_to_integer(lists.delete($\n, Second))
|
||||
|
||||
io.format("Sum: ~p~n", [A + B])
|
||||
io.format("Difference: ~p~n", [A - B])
|
||||
io.format("Product: ~p~n", [A * B])
|
||||
io.format("Quotient: ~p~n", [A / B])
|
||||
io.format("Remainder: ~p~n", [A % B])
|
||||
}
|
||||
14
Task/Arithmetic-Integer/Elena/arithmetic-integer.elena
Normal file
14
Task/Arithmetic-Integer/Elena/arithmetic-integer.elena
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#define std'basic'*.
|
||||
#define math'* = std'math'*.
|
||||
|
||||
#symbol Program =
|
||||
[
|
||||
#var a := 'program'input >> Integer.
|
||||
#var b := 'program'input >> Integer.
|
||||
|
||||
'program'output << a << " + " << b << " = " << a + b << "%n".
|
||||
'program'output << a << " - " << b << " = " << a - b << "%n".
|
||||
'program'output << a << " * " << b << " = " << a * b << "%n".
|
||||
'program'output << a << " / " << b << " = " << a / b << "%n". // truncates towards 0
|
||||
'program'output << a << " %% " << b << " = " << a~math'eops math'modulus:b << "%n". // matches sign of first operand
|
||||
].
|
||||
13
Task/Arithmetic-Integer/Euphoria/arithmetic-integer.euphoria
Normal file
13
Task/Arithmetic-Integer/Euphoria/arithmetic-integer.euphoria
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
include get.e
|
||||
|
||||
integer a,b
|
||||
|
||||
a = floor(prompt_number("a = ",{}))
|
||||
b = floor(prompt_number("b = ",{}))
|
||||
|
||||
printf(1,"a + b = %d\n", a+b)
|
||||
printf(1,"a - b = %d\n", a-b)
|
||||
printf(1,"a * b = %d\n", a*b)
|
||||
printf(1,"a / b = %g\n", a/b) -- does not truncate
|
||||
printf(1,"remainder(a,b) = %d\n", remainder(a,b)) -- same sign as first operand
|
||||
printf(1,"power(a,b) = %g\n", power(a,b))
|
||||
Loading…
Add table
Add a link
Reference in a new issue