langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
22
Task/Integer-comparison/NSIS/integer-comparison-1.nsis
Normal file
22
Task/Integer-comparison/NSIS/integer-comparison-1.nsis
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Function IntergerComparison
|
||||
Push $0
|
||||
Push $1
|
||||
StrCpy $0 8
|
||||
StrCpy $1 2
|
||||
|
||||
IntCmp $0 $1 Equal Val1Less Val1More
|
||||
|
||||
Equal:
|
||||
DetailPrint "$0 = $1"
|
||||
Goto End
|
||||
Val1Less:
|
||||
DetailPrint "$0 < $1"
|
||||
Goto End
|
||||
Val1More:
|
||||
DetailPrint "$0 > $1"
|
||||
Goto End
|
||||
End:
|
||||
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
18
Task/Integer-comparison/NSIS/integer-comparison-2.nsis
Normal file
18
Task/Integer-comparison/NSIS/integer-comparison-2.nsis
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Function IntegerComparison
|
||||
Push $0
|
||||
Push $1
|
||||
|
||||
StrCpy $0 8
|
||||
StrCpy $1 2
|
||||
|
||||
${If} $0 == $1
|
||||
DetailPrint "$0 = $1"
|
||||
${ElseIf} $0 < $1
|
||||
DetailPrint "$0 < $1"
|
||||
${ElseIf} $0 > $1
|
||||
DetailPrint "$0 > $1"
|
||||
${EndIf}
|
||||
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
31
Task/Integer-comparison/Nemerle/integer-comparison.nemerle
Normal file
31
Task/Integer-comparison/Nemerle/integer-comparison.nemerle
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Console;
|
||||
|
||||
module IntComp
|
||||
{
|
||||
Main() : void
|
||||
{
|
||||
def ReadInt() : int {Int32.Parse(ReadLine())}
|
||||
def WriteResult(x : int, y : int, res : string) : void
|
||||
{WriteLine($"$x is $res $y")}
|
||||
|
||||
def a = ReadInt();
|
||||
def b = ReadInt();
|
||||
|
||||
match(a)
|
||||
{
|
||||
|a when a > b => WriteResult(a, b, "greater than")
|
||||
|a when a < b => WriteResult(a, b, "less than")
|
||||
|a when a == b => WriteResult(a, b, "equal to")
|
||||
}
|
||||
|
||||
def x = a.CompareTo(b);
|
||||
|
||||
match(x)
|
||||
{
|
||||
|x when x > 0 => WriteResult(a, b, "greater than")
|
||||
|x when x < 0 => WriteResult(a, b, "less than")
|
||||
|x when x == 0 => WriteResult(a, b, "equal to")
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Task/Integer-comparison/NetRexx/integer-comparison.netrexx
Normal file
15
Task/Integer-comparison/NetRexx/integer-comparison.netrexx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
numL = 0
|
||||
numR = 0
|
||||
loop label running forever
|
||||
say 'Provide two integers [or anything else to stop]:'
|
||||
parse ask numL numR .
|
||||
if \numL.datatype('w') | \numR.datatype('w') then leave running
|
||||
if numL < numR then say numL 'is less than' numR
|
||||
if numL = numR then say numL 'is equal to' numR
|
||||
if numL > numR then say numL 'is greater than' numR
|
||||
end running
|
||||
|
||||
return
|
||||
10
Task/Integer-comparison/OCaml/integer-comparison.ocaml
Normal file
10
Task/Integer-comparison/OCaml/integer-comparison.ocaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
let my_compare a b =
|
||||
if a < b then "A is less than B"
|
||||
else if a > b then "A is greater than B"
|
||||
else if a = b then "A equals B"
|
||||
else "cannot compare NANs"
|
||||
|
||||
let () =
|
||||
let a = read_int ()
|
||||
and b = read_int () in
|
||||
print_endline (my_compare a b)
|
||||
26
Task/Integer-comparison/Oberon-2/integer-comparison.oberon-2
Normal file
26
Task/Integer-comparison/Oberon-2/integer-comparison.oberon-2
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
MODULE Compare;
|
||||
|
||||
IMPORT In, Out;
|
||||
|
||||
VAR a,b: INTEGER;
|
||||
|
||||
BEGIN
|
||||
In.Int(a);
|
||||
In.Int(b);
|
||||
IF a < b THEN
|
||||
Out.Int(a,0);
|
||||
Out.String(" is less than ");
|
||||
Out.Int(b,0);
|
||||
Out.Ln;
|
||||
ELSIF a = b THEN
|
||||
Out.Int(a,0);
|
||||
Out.String(" is equal to ");
|
||||
Out.Int(b,0);
|
||||
Out.Ln;
|
||||
ELSIF a > b THEN
|
||||
Out.Int(a,0);
|
||||
Out.String(" is greater than ");
|
||||
Out.Int(b,0);
|
||||
Out.Ln;
|
||||
END;
|
||||
END Compare.
|
||||
20
Task/Integer-comparison/Objeck/integer-comparison.objeck
Normal file
20
Task/Integer-comparison/Objeck/integer-comparison.objeck
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
bundle Default {
|
||||
class IntCompare {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
a := Console->GetInstance()->ReadString()->ToInt();
|
||||
b := Console->GetInstance()->ReadString()->ToInt();
|
||||
|
||||
if (a < b) {
|
||||
Console->GetInstance()->Print(a)->Print(" is less than ")->PrintLine(b);
|
||||
};
|
||||
|
||||
if (a = b) {
|
||||
Console->GetInstance()->Print(a)->Print(" is equal than ")->PrintLine(b);
|
||||
};
|
||||
|
||||
if (a > b) {
|
||||
Console->GetInstance()->Print(a)->Print(" is greater than ")->PrintLine(b);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Task/Integer-comparison/Octave/integer-comparison.octave
Normal file
11
Task/Integer-comparison/Octave/integer-comparison.octave
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
printf("Enter a: ");
|
||||
a = scanf("%d", "C");
|
||||
printf("Enter b: ");
|
||||
b = scanf("%d", "C");
|
||||
if (a > b)
|
||||
disp("a greater than b");
|
||||
elseif (a == b)
|
||||
disp("a equal to b");
|
||||
elseif (a < b)
|
||||
disp("a less than b");
|
||||
endif
|
||||
28
Task/Integer-comparison/Oz/integer-comparison.oz
Normal file
28
Task/Integer-comparison/Oz/integer-comparison.oz
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
functor
|
||||
import
|
||||
Application(exit)
|
||||
Open(text file)
|
||||
define
|
||||
|
||||
Txt = class from Open.file Open.text end
|
||||
Stdout = {New Open.file init(name:stdout)}
|
||||
Stdin = {New Txt init(name:stdin)}
|
||||
|
||||
proc{Print Msg}
|
||||
{Stdout write(vs:Msg)}
|
||||
end
|
||||
|
||||
fun{GetInt Prompt}
|
||||
{Print Prompt}
|
||||
{StringToInt {Stdin getS($)}}
|
||||
end
|
||||
|
||||
Int1 = {GetInt "Enter 1st Integer:"}
|
||||
Int2 = {GetInt "Enter 2nd Integer:"}
|
||||
|
||||
if(Int1 < Int2) then {Print Int1#" less than "#Int2} end
|
||||
if(Int1 > Int2) then {Print Int1#" greater than "#Int2} end
|
||||
if(Int1 == Int2) then {Print Int1#" equal to "#Int2} end
|
||||
|
||||
{Application.exit 0}
|
||||
end
|
||||
5
Task/Integer-comparison/PARI-GP/integer-comparison.pari
Normal file
5
Task/Integer-comparison/PARI-GP/integer-comparison.pari
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a=input();
|
||||
b=input();
|
||||
if(a<b, print(a" < "b));
|
||||
if(a==b, print(a" = "b));
|
||||
if(a>b, print(a" > "b));
|
||||
9
Task/Integer-comparison/PL-I/integer-comparison.pli
Normal file
9
Task/Integer-comparison/PL-I/integer-comparison.pli
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
declare (a, b) fixed binary;
|
||||
|
||||
get list (a, b);
|
||||
if a = b then
|
||||
put skip list ('The numbers are equal');
|
||||
if a > b then
|
||||
put skip list ('The first number is greater than the second');
|
||||
if a < b then
|
||||
put skip list ('The second number is greater than the first');
|
||||
14
Task/Integer-comparison/Pascal/integer-comparison.pascal
Normal file
14
Task/Integer-comparison/Pascal/integer-comparison.pascal
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
program compare(input, output);
|
||||
|
||||
var
|
||||
a, b: integer;
|
||||
|
||||
begin
|
||||
write('Input an integer number: ');
|
||||
readln(a);
|
||||
write('Input another integer number: ');
|
||||
readln(b);
|
||||
if (a < b) then writeln(a, ' is less than ', b);
|
||||
if (a = b) then writeln(a, ' is equal to ', b);
|
||||
if (a > b) then writeln(a, ' is greater than ', b);
|
||||
end.
|
||||
12
Task/Integer-comparison/Perl-6/integer-comparison-1.pl6
Normal file
12
Task/Integer-comparison/Perl-6/integer-comparison-1.pl6
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
my Int $a = floor $*IN.get;
|
||||
my Int $b = floor $*IN.get;
|
||||
|
||||
if $a < $b {
|
||||
say 'Less';
|
||||
}
|
||||
elsif $a > $b {
|
||||
say 'Greater';
|
||||
}
|
||||
elsif $a == $b {
|
||||
say 'Equal';
|
||||
}
|
||||
1
Task/Integer-comparison/Perl-6/integer-comparison-2.pl6
Normal file
1
Task/Integer-comparison/Perl-6/integer-comparison-2.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
say <Less Equal Greater>[($a cmp $b) + 1];
|
||||
17
Task/Integer-comparison/Pike/integer-comparison.pike
Normal file
17
Task/Integer-comparison/Pike/integer-comparison.pike
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
int main(int argc, array(int) argv){
|
||||
if(argc != 3){
|
||||
write("usage: `pike compare-two-ints.pike <x> <y>` where x and y are integers.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int a = argv[1];
|
||||
int b = argv[2];
|
||||
|
||||
if(a > b) {
|
||||
write(a + " is greater than " + b + "\n");
|
||||
} else if (a < b) {
|
||||
write(a + " is less than " + b + "\n");
|
||||
} else {
|
||||
write(a + " is equal to " + b + "\n");
|
||||
}
|
||||
}
|
||||
17
Task/Integer-comparison/Pop11/integer-comparison.pop11
Normal file
17
Task/Integer-comparison/Pop11/integer-comparison.pop11
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
;;; Comparison procedure
|
||||
define compare_integers(x, y);
|
||||
if x > y then
|
||||
printf('x is greater than y\n');
|
||||
elseif x < y then
|
||||
printf('x is less than y\n');
|
||||
elseif x = y then
|
||||
printf('x equals y\n');
|
||||
endif;
|
||||
enddefine;
|
||||
|
||||
;;; Setup token reader
|
||||
vars itemrep;
|
||||
incharitem(charin) -> itemrep;
|
||||
|
||||
;;; Read numbers and call comparison procedure
|
||||
compare_integers(itemrep(), itemrep());
|
||||
10
Task/Integer-comparison/PowerShell/integer-comparison.psh
Normal file
10
Task/Integer-comparison/PowerShell/integer-comparison.psh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
$a = [int] (Read-Host a)
|
||||
$b = [int] (Read-Host b)
|
||||
|
||||
if ($a -lt $b) {
|
||||
Write-Host $a is less than $b`.
|
||||
} elseif ($a -eq $b) {
|
||||
Write-Host $a is equal to $b`.
|
||||
} elseif ($a -gt $b) {
|
||||
Write-Host $a is greater than $b`.
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
If OpenConsole()
|
||||
|
||||
Print("Enter an integer: ")
|
||||
x.i = Val(Input())
|
||||
Print("Enter another integer: ")
|
||||
y.i = Val(Input())
|
||||
|
||||
If x < y
|
||||
Print( "The first integer is less than the second integer.")
|
||||
ElseIf x = y
|
||||
Print("The first integer is equal to the second integer.")
|
||||
ElseIf x > y
|
||||
Print("The first integer is greater than the second integer.")
|
||||
EndIf
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
|
||||
Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
15
Task/Integer-comparison/REBOL/integer-comparison.rebol
Normal file
15
Task/Integer-comparison/REBOL/integer-comparison.rebol
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
REBOL [
|
||||
Title: "Comparing Two Integers"
|
||||
Author: oofoe
|
||||
Date: 2009-12-04
|
||||
URL: http://rosettacode.org/wiki/Comparing_two_integers
|
||||
]
|
||||
|
||||
a: ask "First integer? " b: ask "Second integer? "
|
||||
|
||||
relation: [
|
||||
a < b "less than"
|
||||
a = b "equal to"
|
||||
a > b "greater than"
|
||||
]
|
||||
print [a "is" case relation b]
|
||||
5
Task/Integer-comparison/Retro/integer-comparison-1.retro
Normal file
5
Task/Integer-comparison/Retro/integer-comparison-1.retro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
: example ( ab- )
|
||||
cons
|
||||
[ do > [ "A > B\n" puts ] ifTrue ]
|
||||
[ do < [ "A < B\n" puts ] ifTrue ]
|
||||
[ do = [ "A = B\n" puts ] ifTrue ] tri ;
|
||||
5
Task/Integer-comparison/Retro/integer-comparison-2.retro
Normal file
5
Task/Integer-comparison/Retro/integer-comparison-2.retro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
: example ( ab- )
|
||||
getToken getToken &toNumber bi@ cons
|
||||
[ do > [ "A > B\n" puts ] ifTrue ]
|
||||
[ do < [ "A < B\n" puts ] ifTrue ]
|
||||
[ do = [ "A = B\n" puts ] ifTrue ] tri ;
|
||||
6
Task/Integer-comparison/Run-BASIC/integer-comparison.run
Normal file
6
Task/Integer-comparison/Run-BASIC/integer-comparison.run
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
input "1st number:"; n1
|
||||
input "2nd number:"; n2
|
||||
|
||||
if n1 < n2 then print "1st number ";n1;" is less than 2nd number";n2
|
||||
if n1 > n2 then print "1st number ";n1;" is greater than 2nd number";n2
|
||||
if n1 = n2 then print "1st number ";n1;" is equal to 2nd number";n2
|
||||
23
Task/Integer-comparison/SAS/integer-comparison.sas
Normal file
23
Task/Integer-comparison/SAS/integer-comparison.sas
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* Showing operators and their fortran-like equivalents. Note that ~= and ^= both mean "different" */
|
||||
data _null_;
|
||||
input a b;
|
||||
put a= b=;
|
||||
if a = b then put "a = b";
|
||||
if a ^= b then put "a ^= b";
|
||||
if a ~= b then put "a ~= b";
|
||||
if a < b then put "a < b";
|
||||
if a > b then put "a > b";
|
||||
if a <= b then put "a <= b";
|
||||
if a >= b then put "a >= b";
|
||||
if a eq b then put "a eq b";
|
||||
if a ne b then put "a ne b";
|
||||
if a lt b then put "a lt b";
|
||||
if a gt b then put "a gt b";
|
||||
if a le b then put "a le b";
|
||||
if a ge b then put "a ge b";
|
||||
cards;
|
||||
1 2
|
||||
2 1
|
||||
1 1
|
||||
;
|
||||
run;
|
||||
8
Task/Integer-comparison/SNOBOL4/integer-comparison.sno
Normal file
8
Task/Integer-comparison/SNOBOL4/integer-comparison.sno
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
* # Get user input
|
||||
output = 'Enter X,Y:'
|
||||
trim(input) break(',') . x ',' rem . y
|
||||
|
||||
output = lt(x,y) x ' is less than ' y :s(end)
|
||||
output = eq(x,y) x ' is equal to ' y :s(end)
|
||||
output = gt(x,y) x ' is greater than ' y
|
||||
end
|
||||
22
Task/Integer-comparison/Seed7/integer-comparison.seed7
Normal file
22
Task/Integer-comparison/Seed7/integer-comparison.seed7
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var integer: a is 0;
|
||||
var integer: b is 0;
|
||||
begin
|
||||
readln(a);
|
||||
readln(b);
|
||||
|
||||
if a < b then
|
||||
writeln(a <& " is less than " <& b);
|
||||
end if;
|
||||
|
||||
if a = b then
|
||||
writeln(a <& " is equal to " <& b);
|
||||
end if;
|
||||
|
||||
if a > b then
|
||||
writeln(a <& " is greater than " <& b);
|
||||
end if;
|
||||
end func;
|
||||
7
Task/Integer-comparison/Slate/integer-comparison.slate
Normal file
7
Task/Integer-comparison/Slate/integer-comparison.slate
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[ |:a :b |
|
||||
|
||||
( a > b ) ifTrue: [ inform: 'a greater than b\n' ].
|
||||
( a < b ) ifTrue: [ inform: 'a less than b\n' ].
|
||||
( a = b ) ifTrue: [ inform: 'a is equal to b\n' ].
|
||||
|
||||
] applyTo: {Integer readFrom: (query: 'Enter a: '). Integer readFrom: (query: 'Enter b: ')}.
|
||||
14
Task/Integer-comparison/Standard-ML/integer-comparison-1.ml
Normal file
14
Task/Integer-comparison/Standard-ML/integer-comparison-1.ml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
fun compare_integers(a, b) =
|
||||
if a < b then print "A is less than B\n"
|
||||
if a > b then print "A is greater than B\n"
|
||||
if a = b then print "A equals B\n"
|
||||
|
||||
fun test () =
|
||||
let
|
||||
open TextIO
|
||||
val SOME a = Int.fromString (input stdIn)
|
||||
val SOME b = Int.fromString (input stdIn)
|
||||
in
|
||||
compare_integers (a, b)
|
||||
end
|
||||
handle Bind => print "Invalid number entered!\n"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
fun myCompare (a, b) = case Int.compare (a, b) of
|
||||
LESS => "A is less than B"
|
||||
| GREATER => "A is greater than B"
|
||||
| EQUAL => "A equals B"
|
||||
12
Task/Integer-comparison/TI-89-BASIC/integer-comparison.ti-89
Normal file
12
Task/Integer-comparison/TI-89-BASIC/integer-comparison.ti-89
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Local a, b, result
|
||||
Prompt a, b
|
||||
If a < b Then
|
||||
"<" → result
|
||||
ElseIf a = b Then
|
||||
"=" → result
|
||||
ElseIf a > b Then
|
||||
">" → result
|
||||
Else
|
||||
"???" → result
|
||||
EndIf
|
||||
Disp string(a) & " " & result & " " & string(b)
|
||||
10
Task/Integer-comparison/TUSCRIPT/integer-comparison.tuscript
Normal file
10
Task/Integer-comparison/TUSCRIPT/integer-comparison.tuscript
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
$$ MODE TUSCRIPT
|
||||
|
||||
ASK "Please enter your first integer:": i1=""
|
||||
ASK "Please enter your second integer:": i2=""
|
||||
|
||||
IF (i1!='digits'||i2!='digits') ERROR/STOP "Please insert digits"
|
||||
|
||||
IF (i1==i2) PRINT i1," is equal to ",i2
|
||||
IF (i1<i2) PRINT i1," is less than ",i2
|
||||
IF (i1>i2) PRINT i1," is greater than ",i2
|
||||
9
Task/Integer-comparison/Toka/integer-comparison.toka
Normal file
9
Task/Integer-comparison/Toka/integer-comparison.toka
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[ ( a b -- )
|
||||
2dup < [ ." a is less than b\n" ] ifTrue
|
||||
2dup > [ ." a is greater than b\n" ] ifTrue
|
||||
= [ ." a is equal to b\n" ] ifTrue
|
||||
] is compare-integers
|
||||
|
||||
1 1 compare-integers
|
||||
2 1 compare-integers
|
||||
1 2 compare-integers
|
||||
22
Task/Integer-comparison/UNIX-Shell/integer-comparison-1.sh
Normal file
22
Task/Integer-comparison/UNIX-Shell/integer-comparison-1.sh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/ksh
|
||||
# tested with ksh93s+
|
||||
|
||||
builtin printf
|
||||
|
||||
integer a=0
|
||||
integer b=0
|
||||
|
||||
read a?"Enter value of a: " || { print -u2 "Input of a aborted." ; exit 1 ; }
|
||||
read b?"Enter value of b: " || { print -u2 "Input of b aborted." ; exit 1 ; }
|
||||
|
||||
if (( a < b )) ; then
|
||||
printf "%d is less than %d\n" a b
|
||||
fi
|
||||
if (( a == b )) ; then
|
||||
printf "%d is equal to %d\n" a b
|
||||
fi
|
||||
if (( a > b )) ; then
|
||||
printf "%d is greater than %d\n" a b
|
||||
fi
|
||||
|
||||
exit 0
|
||||
20
Task/Integer-comparison/UNIX-Shell/integer-comparison-2.sh
Normal file
20
Task/Integer-comparison/UNIX-Shell/integer-comparison-2.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/ksh
|
||||
# tested with pdksh
|
||||
|
||||
integer a=0
|
||||
integer b=0
|
||||
|
||||
read a?"Enter value of a: " || { print -u2 "Input of a aborted." ; exit 1 ; }
|
||||
read b?"Enter value of b: " || { print -u2 "Input of b aborted." ; exit 1 ; }
|
||||
|
||||
if (( a < b )) ; then
|
||||
printf "%d is less than %d\n" $a $b
|
||||
fi
|
||||
if (( a == b )) ; then
|
||||
printf "%d is equal to %d\n" $a $b
|
||||
fi
|
||||
if (( a > b )) ; then
|
||||
printf "%d is greater than %d\n" $a $b
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
read -p "Enter two integers: " a b
|
||||
|
||||
if [ $a -gt $b ]; then comparison="greater than"
|
||||
elif [ $a -lt $b ]; then comparison="less than"
|
||||
elif [ $a -eq $b ]; then comparison="equal to"
|
||||
else comparison="not comparable to"
|
||||
fi
|
||||
|
||||
echo "${a} is ${comparison} ${b}"
|
||||
12
Task/Integer-comparison/V/integer-comparison.v
Normal file
12
Task/Integer-comparison/V/integer-comparison.v
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[compare
|
||||
[ [>] ['less than' puts]
|
||||
[<] ['greater than' puts]
|
||||
[=] ['is equal' puts]
|
||||
] when].
|
||||
|
||||
|2 3 compare
|
||||
greater than
|
||||
|3 2 compare
|
||||
less than
|
||||
|2 2 compare
|
||||
is equal
|
||||
27
Task/Integer-comparison/VBScript/integer-comparison.vbscript
Normal file
27
Task/Integer-comparison/VBScript/integer-comparison.vbscript
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
option explicit
|
||||
|
||||
function eef( b, r1, r2 )
|
||||
if b then
|
||||
eef = r1
|
||||
else
|
||||
eef = r2
|
||||
end if
|
||||
end function
|
||||
|
||||
dim a, b
|
||||
wscript.stdout.write "First integer: "
|
||||
a = cint(wscript.stdin.readline) 'force to integer
|
||||
|
||||
wscript.stdout.write "Second integer: "
|
||||
b = cint(wscript.stdin.readline) 'force to integer
|
||||
|
||||
wscript.stdout.write "First integer is "
|
||||
if a < b then wscript.stdout.write "less than "
|
||||
if a = b then wscript.stdout.write "equal to "
|
||||
if a > b then wscript.stdout.write "greater than "
|
||||
wscript.echo "Second integer."
|
||||
|
||||
wscript.stdout.write "First integer is " & _
|
||||
eef( a < b, "less than ", _
|
||||
eef( a = b, "equal to ", _
|
||||
eef( a > b, "greater than ", vbnullstring ) ) ) & "Second integer."
|
||||
17
Task/Integer-comparison/Vala/integer-comparison.vala
Normal file
17
Task/Integer-comparison/Vala/integer-comparison.vala
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
void main(){
|
||||
int a;
|
||||
int b;
|
||||
|
||||
stdout.printf("Please type in int 1\n");
|
||||
a = int.parse(stdin.read_line());
|
||||
|
||||
stdout.printf("Please type in int 2\n");
|
||||
b = int.parse(stdin.read_line());
|
||||
|
||||
if (a < b)
|
||||
stdout.printf("%d is less than %d\n", a, b);
|
||||
if (a == b)
|
||||
stdout.printf("%d is equal to %d\n", a, b);
|
||||
if (a > b)
|
||||
stdout.printf("%d is greater than %d\n", a, b);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Sub Main()
|
||||
|
||||
Dim a = CInt(Console.ReadLine)
|
||||
Dim b = CInt(Console.ReadLine)
|
||||
|
||||
'Using if statements
|
||||
If a < b Then Console.WriteLine("a is less than b")
|
||||
If a = b Then Console.WriteLine("a equals b")
|
||||
If a > b Then Console.WriteLine("a is greater than b")
|
||||
|
||||
'Using Case
|
||||
Select Case a
|
||||
Case Is < b
|
||||
Console.WriteLine("a is less than b")
|
||||
Case b
|
||||
Console.WriteLine("a equals b")
|
||||
Case Is > b
|
||||
Console.WriteLine("a is greater than b")
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
8
Task/Integer-comparison/XPL0/integer-comparison.xpl0
Normal file
8
Task/Integer-comparison/XPL0/integer-comparison.xpl0
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
code IntIn=10, Text=12;
|
||||
int A, B;
|
||||
[A:= IntIn(0);
|
||||
B:= IntIn(0);
|
||||
if A<B then Text(0, "A<B^M^J");
|
||||
if A=B then Text(0, "A=B^M^J");
|
||||
if A>B then Text(0, "A>B^M^J");
|
||||
]
|
||||
10
Task/Integer-comparison/XSLT/integer-comparison.xslt
Normal file
10
Task/Integer-comparison/XSLT/integer-comparison.xslt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<xsl:template name="compare">
|
||||
<xsl:param name="a" select="1"/>
|
||||
<xsl:param name="b" select="2"/>
|
||||
<fo:block>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$a < $b">a < b</xsl:when>
|
||||
<xsl:when test="$a > $b">a > b</xsl:when>
|
||||
<xsl:when test="$a = $b">a = b</xsl:when>
|
||||
</xsl:choose>
|
||||
</fo:block>
|
||||
Loading…
Add table
Add a link
Reference in a new issue