Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Integer-comparison/00-META.yaml
Normal file
5
Task/Integer-comparison/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Arithmetic operations
|
||||
from: http://rosettacode.org/wiki/Integer_comparison
|
||||
note: Basic Data Operations
|
||||
19
Task/Integer-comparison/00-TASK.txt
Normal file
19
Task/Integer-comparison/00-TASK.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{{basic data operation}}
|
||||
[[Category:Simple]]
|
||||
|
||||
Get two integers from the user.
|
||||
|
||||
Then, display a message if the first integer is:
|
||||
::::* less than,
|
||||
::::* equal to, or
|
||||
::::* greater than
|
||||
the second integer.
|
||||
|
||||
|
||||
Test the condition ''for each case separately'', so that ''all three comparison operators are used'' in the code.
|
||||
|
||||
|
||||
;Related task:
|
||||
* [[String comparison]]
|
||||
<br><br>
|
||||
|
||||
9
Task/Integer-comparison/11l/integer-comparison.11l
Normal file
9
Task/Integer-comparison/11l/integer-comparison.11l
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
V a = Int(input(‘Enter value of a: ’))
|
||||
V b = Int(input(‘Enter value of b: ’))
|
||||
|
||||
I a < b
|
||||
print(‘a is less than b’)
|
||||
I a > b
|
||||
print(‘a is greater than b’)
|
||||
I a == b
|
||||
print(‘a is equal to b’)
|
||||
33
Task/Integer-comparison/360-Assembly/integer-comparison.360
Normal file
33
Task/Integer-comparison/360-Assembly/integer-comparison.360
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
INTCOMP PROLOG
|
||||
* Reg1=Addr(Addr(argA),Addr(argB))
|
||||
L 2,0(1) Reg2=Addr(argA)
|
||||
L 3,4(1) Reg3=Addr(argB)
|
||||
L 4,0(2) Reg4=argA
|
||||
L 5,0(3) Reg5=argA
|
||||
ST 4,A Store R4 in A
|
||||
ST 5,B Store R5 in B
|
||||
* if (A < B)
|
||||
L 0,A load R0
|
||||
C 0,B compare
|
||||
BL LOWER branch if lower
|
||||
* if (A = B)
|
||||
L 0,A load R0
|
||||
C 0,B compare
|
||||
BE EQUAL branch if equal
|
||||
* if (A < B)
|
||||
L 0,A load R0
|
||||
C 0,B compare
|
||||
BH GREATER branch if higher
|
||||
* other case ?
|
||||
B RETURN
|
||||
LOWER WTO 'A<B'
|
||||
B RETURN
|
||||
EQUAL WTO 'A=B'
|
||||
B RETURN
|
||||
GREATER WTO 'A>B'
|
||||
B RETURN
|
||||
*
|
||||
RETURN EPILOG
|
||||
A DS F 31-bit signed integer
|
||||
B DS F 31-bit signed integer
|
||||
END
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Compare PHA ;push Accumulator onto stack
|
||||
JSR GetUserInput ;routine not implemented
|
||||
;integers to compare now in memory locations A and B
|
||||
LDA A
|
||||
CMP B ;sets flags as if a subtraction (a - b) had been carried out
|
||||
BCC A_less_than_B ;branch if carry clear
|
||||
BEQ A_equals_B ;branch if equal
|
||||
;else A greater than B
|
||||
JSR DisplayAGreaterThanB;routine not implemented
|
||||
JMP Done
|
||||
A_less_than_B: JSR DisplayALessThanB ;routine not implemented
|
||||
JMP Done
|
||||
A_equals_B: JSR DisplayAEqualsB ;routine not implemented
|
||||
Done: PLA ;restore Accumulator from stack
|
||||
RTS ;return from subroutine
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
Compare:
|
||||
;integers to compare are in D0 and D1
|
||||
CMP.L D1,D0
|
||||
BCS .less ;D1 < D0
|
||||
;else, carry clear, which implies greater than or equal to.
|
||||
BNE .greater ;D1 > D0
|
||||
;else, d1 = d0
|
||||
LEA Equal,A0
|
||||
JMP PrintString ;and use its RTS to return
|
||||
.greater:
|
||||
LEA GreaterThan,A0
|
||||
JMP PrintString ;and use its RTS to return
|
||||
.less:
|
||||
LEA LessThan,A0
|
||||
JMP PrintString ;and use its RTS to return
|
||||
|
||||
|
||||
LessThan:
|
||||
dc.b "second integer less than first",0
|
||||
even
|
||||
GreaterThan:
|
||||
dc.b "second integer greater than first",0
|
||||
even
|
||||
Equal:
|
||||
dc.b "both are equal",0
|
||||
even
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
Compare:
|
||||
;integers to compare are in D0 and D1
|
||||
CMP.L D1,D0
|
||||
BLT .less ;D1 < D0
|
||||
;else, carry clear, which implies greater than or equal to.
|
||||
BNE .greater ;D1 > D0
|
||||
;else, d1 = d0
|
||||
LEA Equal,A0
|
||||
JMP PrintString ;and use its RTS to return
|
||||
.greater:
|
||||
LEA GreaterThan,A0
|
||||
JMP PrintString ;and use its RTS to return
|
||||
.less:
|
||||
LEA LessThan,A0
|
||||
JMP PrintString ;and use its RTS to return
|
||||
|
||||
|
||||
LessThan:
|
||||
dc.b "second integer less than first",0
|
||||
even
|
||||
GreaterThan:
|
||||
dc.b "second integer greater than first",0
|
||||
even
|
||||
Equal:
|
||||
dc.b "both are equal",0
|
||||
even
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
compare:
|
||||
push psw
|
||||
cjne a, b, clt
|
||||
; a == b
|
||||
; implement code here
|
||||
jmp compare_
|
||||
clt:
|
||||
jc lt
|
||||
; a > b
|
||||
; implement code here
|
||||
jmp compare_
|
||||
lt:
|
||||
; a < b
|
||||
; implement code here
|
||||
compare_:
|
||||
pop psw
|
||||
ret
|
||||
4
Task/Integer-comparison/8th/integer-comparison.8th
Normal file
4
Task/Integer-comparison/8th/integer-comparison.8th
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
: compare \ n m --
|
||||
2dup n:= if "They are equal" . cr then
|
||||
2dup n:< if "First less than second" . cr then
|
||||
n:> if "First greater than second" . cr then ;
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
.equ STDOUT, 1
|
||||
.equ SVC_WRITE, 64
|
||||
.equ SVC_EXIT, 93
|
||||
|
||||
.text
|
||||
.global _start
|
||||
|
||||
_start:
|
||||
stp x29, x30, [sp, -16]!
|
||||
mov x0, #123
|
||||
mov x1, #456
|
||||
mov x29, sp
|
||||
bl integer_compare // integer_compare(123, 456);
|
||||
mov x0, #-123
|
||||
mov x1, #-456
|
||||
bl integer_compare // integer_compare(-123, -456);
|
||||
mov x0, #123
|
||||
mov x1, #123
|
||||
bl integer_compare // integer_compare(123, 123);
|
||||
ldp x29, x30, [sp], 16
|
||||
mov x0, #0
|
||||
b _exit // exit(0);
|
||||
|
||||
// void integer_compare(long long x, long long y) - compare two signed integers and print a message
|
||||
integer_compare:
|
||||
cmp x0, x1
|
||||
mov x0, #STDOUT
|
||||
b.eq 1f
|
||||
b.gt 2f
|
||||
// x < y
|
||||
ldr x1, =msg_lt
|
||||
mov x2, #17
|
||||
b _write
|
||||
1: // x == y
|
||||
ldr x1, =msg_eq
|
||||
mov x2, #16
|
||||
b _write
|
||||
2: // x > y
|
||||
ldr x1, =msg_gt
|
||||
mov x2, #20
|
||||
b _write
|
||||
|
||||
msg_lt:
|
||||
.ascii "x is less than y\n"
|
||||
msg_eq:
|
||||
.ascii "x is equal to y\n"
|
||||
msg_gt:
|
||||
.ascii "x is greater than y\n"
|
||||
.align 4
|
||||
|
||||
//////////////// system call wrappers
|
||||
// ssize_t _write(int fd, void *buf, size_t count)
|
||||
_write:
|
||||
stp x29, x30, [sp, -16]!
|
||||
mov x8, #SVC_WRITE
|
||||
mov x29, sp
|
||||
svc #0
|
||||
ldp x29, x30, [sp], 16
|
||||
ret
|
||||
|
||||
// void _exit(int retval)
|
||||
_exit:
|
||||
mov x8, #SVC_EXIT
|
||||
svc #0
|
||||
13
Task/Integer-comparison/ABAP/integer-comparison.abap
Normal file
13
Task/Integer-comparison/ABAP/integer-comparison.abap
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
report z_integer_comparison.
|
||||
|
||||
parameters: a type int4, b type int4.
|
||||
|
||||
data(comparison_result) = cond string(
|
||||
when a < b " can be replaced by a lt b
|
||||
then |{ a } is less than { b }|
|
||||
when a = b " can be replaced by a eq b
|
||||
then |{ a } is equal to { b }|
|
||||
when a > b " can be replaced by a gt b
|
||||
then |{ a } is greater than { b }| ).
|
||||
|
||||
write comparison_result.
|
||||
21
Task/Integer-comparison/ALGOL-68/integer-comparison.alg
Normal file
21
Task/Integer-comparison/ALGOL-68/integer-comparison.alg
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
main: (
|
||||
INT a, b;
|
||||
read((a, space, b, new line));
|
||||
|
||||
IF a <= b OR a LE b # OR a ≤ b # THEN
|
||||
print((a," is less or equal to ", b, new line))
|
||||
FI;
|
||||
IF a < b OR a LT b THEN
|
||||
print((a," is less than ", b, new line))
|
||||
ELIF a = b OR a EQ b THEN
|
||||
print((a," is equal to ", b, new line))
|
||||
ELIF a > b OR a GT b THEN
|
||||
print((a," is greater than ", b, new line))
|
||||
FI;
|
||||
IF a /= b OR a NE b # OR a ≠ b # THEN
|
||||
print((a," is not equal to ", b, new line))
|
||||
FI;
|
||||
IF a >= b OR a GE b # OR a ≥ b # THEN
|
||||
print((a," is greater or equal to ", b, new line))
|
||||
FI
|
||||
)
|
||||
14
Task/Integer-comparison/ALGOL-W/integer-comparison.alg
Normal file
14
Task/Integer-comparison/ALGOL-W/integer-comparison.alg
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
begin
|
||||
|
||||
integer a, b;
|
||||
|
||||
write( "first number: " );
|
||||
read( a );
|
||||
write( "second number: " );
|
||||
read( b );
|
||||
|
||||
if a < b then write( a, " is less than ", b );
|
||||
if a = b then write( a, " is equal to ", b );
|
||||
if a > b then write( a, " is greater than ", b );
|
||||
|
||||
end.
|
||||
181
Task/Integer-comparison/ARM-Assembly/integer-comparison.arm
Normal file
181
Task/Integer-comparison/ARM-Assembly/integer-comparison.arm
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program comparNumber.s */
|
||||
|
||||
/* Constantes */
|
||||
.equ BUFFERSIZE, 100
|
||||
.equ STDIN, 0 @ Linux input console
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ READ, 3 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
/* Initialized data */
|
||||
.data
|
||||
szMessNum1: .asciz "Enter number 1 : \n"
|
||||
szMessNum2: .asciz "Enter number 2: \n"
|
||||
szMessEqual: .asciz "Number 1 and number 2 are equals.\n"
|
||||
szMessSmall: .asciz "Number 1 smaller than number 2.\n"
|
||||
szMessLarge: .asciz "Number 1 larger than number 2.\n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
|
||||
/* UnInitialized data */
|
||||
.bss
|
||||
sBuffer: .skip BUFFERSIZE
|
||||
|
||||
/* code section */
|
||||
.text
|
||||
.global main
|
||||
main: /* entry of program */
|
||||
push {fp,lr} /* saves 2 registers */
|
||||
ldr r0,iAdrszMessNum1 @ message address
|
||||
ldr r1,iAdrsBuffer @ buffer address
|
||||
mov r2,#BUFFERSIZE
|
||||
bl numberEntry
|
||||
mov r5,r0 @ save number 1 -> r5
|
||||
ldr r0,iAdrszMessNum2 @ message address
|
||||
ldr r1,iAdrsBuffer @ buffer address
|
||||
mov r2,#BUFFERSIZE
|
||||
bl numberEntry
|
||||
cmp r5,r0 @ compar number 1 and number 2
|
||||
beq equal
|
||||
blt small
|
||||
bgt large
|
||||
@ never !!
|
||||
b 100f
|
||||
equal:
|
||||
ldr r0,iAdrszMessEqual @ message address
|
||||
b aff
|
||||
small:
|
||||
ldr r0,iAdrszMessSmall @ message address
|
||||
b aff
|
||||
large:
|
||||
ldr r0,iAdrszMessLarge @ message address
|
||||
b aff
|
||||
aff:
|
||||
bl affichageMess @ display message
|
||||
|
||||
|
||||
100: /* standard end of the program */
|
||||
mov r0, #0 @ return code
|
||||
pop {fp,lr} @restaur 2 registers
|
||||
mov r7, #EXIT @ request to exit program
|
||||
swi 0 @ perform the system call
|
||||
|
||||
iAdrszMessNum1: .int szMessNum1
|
||||
iAdrszMessNum2: .int szMessNum2
|
||||
iAdrszMessEqual: .int szMessEqual
|
||||
iAdrszMessSmall: .int szMessSmall
|
||||
iAdrszMessLarge: .int szMessLarge
|
||||
iAdrsBuffer: .int sBuffer
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
/******************************************************************/
|
||||
/* Number entry with display message and conversion number */
|
||||
/******************************************************************/
|
||||
/* r0 contains message address */
|
||||
/* r1 contains buffer address
|
||||
/* r2 contains buffersize */
|
||||
/* r0 return a number */
|
||||
numberEntry:
|
||||
push {fp,lr} @ save registres */
|
||||
push {r4,r6,r7} @ save others registers
|
||||
mov r4,r1 @ save buffer address -> r4
|
||||
bl affichageMess
|
||||
mov r0,#STDIN @ Linux input console
|
||||
//ldr r1,iAdrsBuffer @ buffer address
|
||||
//mov r2,#BUFFERSIZE @ buffer size
|
||||
mov r7, #READ @ request to read datas
|
||||
swi 0 @ call system
|
||||
mov r1,r4 @ buffer address
|
||||
mov r2,#0 @ end of string
|
||||
strb r2,[r1,r0] @ store byte at the end of input string (r0
|
||||
@
|
||||
mov r0,r4 @ buffer address
|
||||
bl conversionAtoD @ conversion string in number in r0
|
||||
|
||||
100:
|
||||
pop {r4,r6,r7} /* restaur others registers */
|
||||
pop {fp,lr} /* restaur des 2 registres */
|
||||
bx lr /* return */
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {fp,lr} /* save registres */
|
||||
push {r0,r1,r2,r7} /* save others registers */
|
||||
mov r2,#0 /* counter length */
|
||||
1: /* loop length calculation */
|
||||
ldrb r1,[r0,r2] /* read octet start position + index */
|
||||
cmp r1,#0 /* if 0 its over */
|
||||
addne r2,r2,#1 /* else add 1 in the length */
|
||||
bne 1b /* and loop */
|
||||
/* so here r2 contains the length of the message */
|
||||
mov r1,r0 /* address message in r1 */
|
||||
mov r0,#STDOUT /* code to write to the standard output Linux */
|
||||
mov r7, #WRITE /* code call system "write" */
|
||||
swi #0 /* call systeme */
|
||||
pop {r0,r1,r2,r7} /* restaur others registers */
|
||||
pop {fp,lr} /* restaur des 2 registres */
|
||||
bx lr /* return */
|
||||
|
||||
/******************************************************************/
|
||||
/* Convert a string to a number stored in a registry */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the area terminated by 0 or 0A */
|
||||
/* r0 returns a number */
|
||||
conversionAtoD:
|
||||
push {fp,lr} @ save 2 registers
|
||||
push {r1-r7} @ save others registers
|
||||
mov r1,#0
|
||||
mov r2,#10 @ factor
|
||||
mov r3,#0 @ counter
|
||||
mov r4,r0 @ save address string -> r4
|
||||
mov r6,#0 @ positive sign by default
|
||||
mov r0,#0 @ initialization to 0
|
||||
1: /* early space elimination loop */
|
||||
ldrb r5,[r4,r3] @ loading in r5 of the byte located at the beginning + the position
|
||||
cmp r5,#0 @ end of string -> end routine
|
||||
beq 100f
|
||||
cmp r5,#0x0A @ end of string -> end routine
|
||||
beq 100f
|
||||
cmp r5,#' ' @ space ?
|
||||
addeq r3,r3,#1 @ yes we loop by moving one byte
|
||||
beq 1b
|
||||
cmp r5,#'-' @ first character is -
|
||||
moveq r6,#1 @ 1 -> r6
|
||||
beq 3f @ then move on to the next position
|
||||
2: /* beginning of digit processing loop */
|
||||
cmp r5,#'0' @ character is not a number
|
||||
blt 3f
|
||||
cmp r5,#'9' @ character is not a number
|
||||
bgt 3f
|
||||
/* character is a number */
|
||||
sub r5,#48
|
||||
ldr r1,iMaxi @ check the overflow of the register
|
||||
cmp r0,r1
|
||||
bgt 99f @ overflow error
|
||||
mul r0,r2,r0 @ multiply par factor 10
|
||||
add r0,r5 @ add to r0
|
||||
3:
|
||||
add r3,r3,#1 @ advance to the next position
|
||||
ldrb r5,[r4,r3] @ load byte
|
||||
cmp r5,#0 @ end of string -> end routine
|
||||
beq 4f
|
||||
cmp r5,#0x0A @ end of string -> end routine
|
||||
beq 4f
|
||||
b 2b @ loop
|
||||
4:
|
||||
cmp r6,#1 @ test r6 for sign
|
||||
moveq r1,#-1
|
||||
muleq r0,r1,r0 @ if negatif, multiply par -1
|
||||
b 100f
|
||||
99: /* overflow error */
|
||||
ldr r0,=szMessErrDep
|
||||
bl affichageMess
|
||||
mov r0,#0 @ return zero if error
|
||||
100:
|
||||
pop {r1-r7} @ restaur other registers
|
||||
pop {fp,lr} @ restaur 2 registers
|
||||
bx lr @return procedure
|
||||
/* constante program */
|
||||
iMaxi: .int 1073741824
|
||||
szMessErrDep: .asciz "Too large: overflow 32 bits.\n"
|
||||
5
Task/Integer-comparison/AWK/integer-comparison-1.awk
Normal file
5
Task/Integer-comparison/AWK/integer-comparison-1.awk
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/[0-9]* [0-9]*/{
|
||||
if ($1 == $2) print $1, "is equal to", $2
|
||||
if ($1 < $2) print $1, "is less than", $2
|
||||
if ($1 > $2) print $1, "is greater than", $2
|
||||
}
|
||||
2
Task/Integer-comparison/AWK/integer-comparison-2.awk
Normal file
2
Task/Integer-comparison/AWK/integer-comparison-2.awk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# This code contains a bug
|
||||
IF (n=3) PRINT "n is equal to 3" # The incorrectly used equals sign will set n to a value of 3
|
||||
16
Task/Integer-comparison/Action-/integer-comparison.action
Normal file
16
Task/Integer-comparison/Action-/integer-comparison.action
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
PROC Main()
|
||||
INT a,b
|
||||
|
||||
Print("Input value of a:") a=InputI()
|
||||
Print("Input value of b:") b=InputI()
|
||||
|
||||
IF a<b THEN
|
||||
PrintF("%I is less than %I%E",a,b)
|
||||
FI
|
||||
IF a>b THEN
|
||||
PrintF("%I is greater than %I%E",a,b)
|
||||
FI
|
||||
IF a=b THEN
|
||||
PrintF("%I is equal to %I%E",a,b)
|
||||
FI
|
||||
RETURN
|
||||
24
Task/Integer-comparison/Ada/integer-comparison.ada
Normal file
24
Task/Integer-comparison/Ada/integer-comparison.ada
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Integer_Text_IO; use Ada.Integer_Text_Io;
|
||||
|
||||
procedure Compare_Ints is
|
||||
A, B : Integer;
|
||||
begin
|
||||
Get(Item => A);
|
||||
Get(Item => B);
|
||||
|
||||
-- Test for equality
|
||||
if A = B then
|
||||
Put_Line("A equals B");
|
||||
end if;
|
||||
|
||||
-- Test For Less Than
|
||||
if A < B then
|
||||
Put_Line("A is less than B");
|
||||
end if;
|
||||
|
||||
-- Test For Greater Than
|
||||
if A > B then
|
||||
Put_Line("A is greater than B");
|
||||
end if;
|
||||
end Compare_Ints;
|
||||
27
Task/Integer-comparison/Aime/integer-comparison.aime
Normal file
27
Task/Integer-comparison/Aime/integer-comparison.aime
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
void
|
||||
output(integer a, integer b, text condition)
|
||||
{
|
||||
o_integer(a);
|
||||
o_text(condition);
|
||||
o_integer(b);
|
||||
o_byte('\n');
|
||||
}
|
||||
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
if (a < b) {
|
||||
output(a, b, " is less then ");
|
||||
}
|
||||
|
||||
if (a == b) {
|
||||
output(a, b, " is equal to ");
|
||||
}
|
||||
|
||||
if (a > b) {
|
||||
output(a, b, " is greater than ");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
set n1 to text returned of (display dialog "Enter the first number:" default answer "") as integer
|
||||
set n2 to text returned of (display dialog "Enter the second number:" default answer "") as integer
|
||||
set msg to {n1}
|
||||
if n1 < n2 then
|
||||
set end of msg to " is less than "
|
||||
else if n1 = n2 then
|
||||
set end of msg to " is equal to "
|
||||
else if n1 > n2 then
|
||||
set end of msg to " is greater than "
|
||||
end if
|
||||
set end of msg to n2
|
||||
return msg as string
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
set n1 to text returned of (display dialog "Enter the first number:" default answer "") as integer
|
||||
set n2 to text returned of (display dialog "Enter the second number:" default answer "") as integer
|
||||
if n1 < n2 then return "" & n1 & " is less than " & n2
|
||||
if n1 = n2 then return "" & n1 & " is equal to " & n2
|
||||
if n1 > n2 then return "" & n1 & " is greater than " & n2
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
10 INPUT "ENTER TWO INTEGERS: "; A%, B%
|
||||
20 A$(0) = "NOT "
|
||||
30 PRINT A% " IS " A$(A% < B%) "LESS THAN " B%
|
||||
40 PRINT A% " IS " A$(A% = B%) "EQUAL TO " B%
|
||||
50 PRINT A% " IS " A$(A% > B%) "GREATER THAN " B%
|
||||
6
Task/Integer-comparison/Arturo/integer-comparison.arturo
Normal file
6
Task/Integer-comparison/Arturo/integer-comparison.arturo
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
a: to :integer input "enter a value for a: "
|
||||
b: to :integer input "enter a value for b: "
|
||||
|
||||
if a<b [ print [ a "is less than" b ] ]
|
||||
if a>b [ print [ a "is greater than" b ] ]
|
||||
if a=b [ print [ a "is equal to" b ] ]
|
||||
9
Task/Integer-comparison/Astro/integer-comparison.astro
Normal file
9
Task/Integer-comparison/Astro/integer-comparison.astro
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
let a = input('Enter value of a: ')
|
||||
let b = input('Enter value of b: ')
|
||||
|
||||
if a < b:
|
||||
print 'a is less than b'
|
||||
elif a > b:
|
||||
print 'a is greater than b'
|
||||
elif a == b:
|
||||
print 'a is equal to b'
|
||||
20
Task/Integer-comparison/AutoHotkey/integer-comparison.ahk
Normal file
20
Task/Integer-comparison/AutoHotkey/integer-comparison.ahk
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
Gui, Add, Edit
|
||||
Gui, Add, UpDown, vVar1
|
||||
Gui, Add, Edit
|
||||
Gui, Add, UpDown, vVar2
|
||||
Gui, Add, Button, Default, Submit
|
||||
Gui, Show
|
||||
Return
|
||||
|
||||
ButtonSubmit:
|
||||
Gui, Submit, NoHide
|
||||
If (Var1 = Var2)
|
||||
MsgBox, % Var1 "=" Var2
|
||||
Else If (Var1 < Var2)
|
||||
MsgBox, % Var1 "<" Var2
|
||||
Else If (Var1 > Var2)
|
||||
MsgBox, % Var1 ">" Var2
|
||||
Return
|
||||
|
||||
GuiClose:
|
||||
ExitApp
|
||||
6
Task/Integer-comparison/Avail/integer-comparison.avail
Normal file
6
Task/Integer-comparison/Avail/integer-comparison.avail
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// This code doesn't try to protect against any malformed input.
|
||||
a ::= next line from standard input→integer;
|
||||
b ::= next line from standard input→integer;
|
||||
If a > b then [Print: "a > b";]
|
||||
else if a < b then [Print: "a < b";]
|
||||
else if a = b then [Print: "a = b";];
|
||||
11
Task/Integer-comparison/Axe/integer-comparison.axe
Normal file
11
Task/Integer-comparison/Axe/integer-comparison.axe
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Lbl FUNC
|
||||
If r₁<r₂
|
||||
Disp "LESS THAN",i
|
||||
End
|
||||
If r₁=r₂
|
||||
Disp "EQUAL TO",i
|
||||
End
|
||||
If r₁>r₂
|
||||
Disp "GREATER THAN",i
|
||||
End
|
||||
Return
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
input "Please enter one integer: ", x
|
||||
input "and a second integer: ", y
|
||||
if x < y then print x; " is less than "; y
|
||||
if x = y then print x; " is equal to "; y
|
||||
if x > y then print x; " is greater than "; y
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
INPUT "Enter two numbers separated by a comma: " a, b
|
||||
CASE TRUE OF
|
||||
WHEN a < b: PRINT ;a " is less than "; b
|
||||
WHEN a = b: PRINT ;a " is equal to "; b
|
||||
WHEN a > b: PRINT ;a " is greater than "; b
|
||||
ENDCASE
|
||||
14
Task/Integer-comparison/BCPL/integer-comparison.bcpl
Normal file
14
Task/Integer-comparison/BCPL/integer-comparison.bcpl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
get "libhdr"
|
||||
|
||||
let start() be
|
||||
$( let a = ? and b = ?
|
||||
writes("A? ") ; a := readn()
|
||||
writes("B? ") ; b := readn()
|
||||
|
||||
writes(
|
||||
a < b -> "A is less than B*N",
|
||||
a = b -> "A is equal to B*N",
|
||||
a > b -> "A is greater than B*N",
|
||||
"Huh?!"
|
||||
)
|
||||
$)
|
||||
9
Task/Integer-comparison/BQN/integer-comparison.bqn
Normal file
9
Task/Integer-comparison/BQN/integer-comparison.bqn
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Comp ← ⊑·/⟜"Greater than"‿"Equal To"‿"Lesser Than"(>∾=∾<)
|
||||
⊑(/⟜⟨ "Greater than" "Equal To" "Lesser Than" ⟩>∾=∾<)
|
||||
|
||||
4 Comp 5
|
||||
"Lesser Than"
|
||||
5 Comp 5
|
||||
"Equal To"
|
||||
6 Comp 5
|
||||
"Greater than"
|
||||
5
Task/Integer-comparison/BaCon/integer-comparison-1.bacon
Normal file
5
Task/Integer-comparison/BaCon/integer-comparison-1.bacon
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
INPUT "Enter first number " ,a
|
||||
INPUT "Enter second number " ,b
|
||||
IF a < b THEN PRINT a ," is less than ", b
|
||||
IF a = b THEN PRINT a, " is equal to ", b
|
||||
IF a > b THEN PRINT a, " is greater than ", b
|
||||
7
Task/Integer-comparison/BaCon/integer-comparison-2.bacon
Normal file
7
Task/Integer-comparison/BaCon/integer-comparison-2.bacon
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
CLS
|
||||
INPUT "a, b"; a, b 'remember to type the comma when you give the numbers
|
||||
PRINT "a is ";
|
||||
IF a < b THEN PRINT "less than ";
|
||||
IF a = b THEN PRINT "equal to ";
|
||||
IF a > b THEN PRINT "greater than ";
|
||||
PRINT "b"
|
||||
11
Task/Integer-comparison/Batch-File/integer-comparison.bat
Normal file
11
Task/Integer-comparison/Batch-File/integer-comparison.bat
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
set /p a="A: "
|
||||
set /p b="B: "
|
||||
if %a% LSS %b% (
|
||||
echo %a% is less than %b%
|
||||
) else ( if %a% GTR %b% (
|
||||
echo %a% is greater than %b%
|
||||
) else ( if %a% EQU %b% (
|
||||
echo %a% is equal to %b%
|
||||
)))
|
||||
6
Task/Integer-comparison/Bc/integer-comparison.bc
Normal file
6
Task/Integer-comparison/Bc/integer-comparison.bc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
a = read()
|
||||
b = read()
|
||||
if (a < b) print "a is smaller than b\n"
|
||||
if (a > b) print "a is greater than b\n"
|
||||
if (a == b) print "a is equal to b\n"
|
||||
quit
|
||||
4
Task/Integer-comparison/Befunge/integer-comparison.bf
Normal file
4
Task/Integer-comparison/Befunge/integer-comparison.bf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
v v ">" $<
|
||||
>&&"=A",,\:."=B ",,,\: .55+,-:0`|
|
||||
v "<" _v#<
|
||||
@,+55,," B",,,"A " < "=" <
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
get$:?A
|
||||
& get$:?B
|
||||
& (!A:!B&out$"A equals B"|)
|
||||
& (!A:<!B&out$"A is less than B"|)
|
||||
& (!A:>!B&out$"A is greater than B"|);
|
||||
6
Task/Integer-comparison/Brat/integer-comparison.brat
Normal file
6
Task/Integer-comparison/Brat/integer-comparison.brat
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
first = ask("First integer: ").to_i
|
||||
second = ask("Second integer: ").to_i
|
||||
|
||||
when { first > second } { p "#{first} is greater than #{second}" }
|
||||
{ first < second } { p "#{first} is less than #{second}" }
|
||||
{ first == second } { p "#{first} is equal to #{second}" }
|
||||
6
Task/Integer-comparison/Burlesque/integer-comparison.blq
Normal file
6
Task/Integer-comparison/Burlesque/integer-comparison.blq
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
blsq ) "5 6"ps^pcm+.{"The first one is less than the second one""They are both equal""The second one is less than the first one"}\/!!sh
|
||||
The first one is less than the second one
|
||||
blsq ) "6 6"ps^pcm+.{"The first one is less than the second one""They are both equal""The second one is less than the first one"}\/!!sh
|
||||
They are both equal
|
||||
blsq ) "6 5"ps^pcm+.{"The first one is less than the second one""They are both equal""The second one is less than the first one"}\/!!sh
|
||||
The second one is less than the first one
|
||||
23
Task/Integer-comparison/C++/integer-comparison.cpp
Normal file
23
Task/Integer-comparison/C++/integer-comparison.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a, b;
|
||||
|
||||
if (!(std::cin >> a >> b)) {
|
||||
std::cerr << "could not read the numbers\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// test for less-than
|
||||
if (a < b)
|
||||
std::cout << a << " is less than " << b << "\n";
|
||||
|
||||
// test for equality
|
||||
if (a == b)
|
||||
std::cout << a << " is equal to " << b << "\n";
|
||||
|
||||
// test for greater-than
|
||||
if (a > b)
|
||||
std::cout << a << " is greater than " << b << "\n";
|
||||
}
|
||||
16
Task/Integer-comparison/C-sharp/integer-comparison.cs
Normal file
16
Task/Integer-comparison/C-sharp/integer-comparison.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
int a = int.Parse(Console.ReadLine());
|
||||
int b = int.Parse(Console.ReadLine());
|
||||
if (a < b)
|
||||
Console.WriteLine("{0} is less than {1}", a, b);
|
||||
if (a == b)
|
||||
Console.WriteLine("{0} equals {1}", a, b);
|
||||
if (a > b)
|
||||
Console.WriteLine("{0} is greater than {1}", a, b);
|
||||
}
|
||||
}
|
||||
18
Task/Integer-comparison/C/integer-comparison.c
Normal file
18
Task/Integer-comparison/C/integer-comparison.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
|
||||
if (a < b)
|
||||
printf("%d is less than %d\n", a, b);
|
||||
|
||||
if (a == b)
|
||||
printf("%d is equal to %d\n", a, b);
|
||||
|
||||
if (a > b)
|
||||
printf("%d is greater than %d\n", a, b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
15
Task/Integer-comparison/CFEngine/integer-comparison.cfengine
Normal file
15
Task/Integer-comparison/CFEngine/integer-comparison.cfengine
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
bundle agent __main__
|
||||
{
|
||||
vars:
|
||||
# Change the values to test:
|
||||
"first_integer" int => "10";
|
||||
"second_integer" int => "9";
|
||||
|
||||
reports:
|
||||
"The first integer ($(first_integer)) is less than the second integer ($(second_integer))."
|
||||
if => islessthan( "$(first_integer)", "$(second_integer)" );
|
||||
"The first integer ($(first_integer)) is equal to the second integer ($(second_integer))."
|
||||
if => eval( "$(first_integer)==$(second_integer)", "class", "infix" );
|
||||
"The first integer ($(first_integer)) is greater than the second integer ($(second_integer))."
|
||||
if => isgreaterthan( "$(first_integer)", "$(second_integer)" );
|
||||
}
|
||||
19
Task/Integer-comparison/CMake/integer-comparison.cmake
Normal file
19
Task/Integer-comparison/CMake/integer-comparison.cmake
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Define A and B as integers. For example:
|
||||
# cmake -DA=3 -DB=5 -P compare.cmake
|
||||
|
||||
# The comparisons can take variable names, or they can take numbers.
|
||||
# So these act all the same:
|
||||
# A LESS B
|
||||
# ${A} LESS ${B}
|
||||
# A LESS ${B}
|
||||
# ${A} LESS B
|
||||
|
||||
if(A LESS B)
|
||||
message(STATUS "${A} is less than ${B}")
|
||||
endif()
|
||||
if(A EQUAL B)
|
||||
message(STATUS "${A} is equal to ${B}")
|
||||
endif()
|
||||
if(A GREATER B)
|
||||
message(STATUS "${A} is greater than ${B}")
|
||||
endif()
|
||||
26
Task/Integer-comparison/COBOL/integer-comparison.cobol
Normal file
26
Task/Integer-comparison/COBOL/integer-comparison.cobol
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Int-Compare.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 A PIC 9(10).
|
||||
01 B PIC 9(10).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY "First number: " WITH NO ADVANCING
|
||||
ACCEPT A
|
||||
DISPLAY "Second number: " WITH NO ADVANCING
|
||||
ACCEPT B
|
||||
|
||||
* *> Note: Longer verbal forms may be used instead of symbols
|
||||
* *> e.g. 'IS GREATER THAN' instead '<'
|
||||
IF A < B
|
||||
DISPLAY A " is less than " B
|
||||
ELSE IF A = B
|
||||
DISPLAY A " is equal to " B
|
||||
ELSE IF A > B
|
||||
DISPLAY A " is larger than " B
|
||||
END-IF.
|
||||
|
||||
GOBACK
|
||||
.
|
||||
8
Task/Integer-comparison/ChucK/integer-comparison.chuck
Normal file
8
Task/Integer-comparison/ChucK/integer-comparison.chuck
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fun void intComparison (int one, int two)
|
||||
{
|
||||
if(one < two) <<< one, " is less than ", two >>>;
|
||||
if(one == two) <<< one, " is equal than ", two >>>;
|
||||
if(one > two) <<< one, " is greater than ", two >>>;
|
||||
}
|
||||
// uncomment next line and change values to test
|
||||
// intComparison (2,4);
|
||||
12
Task/Integer-comparison/Clean/integer-comparison.clean
Normal file
12
Task/Integer-comparison/Clean/integer-comparison.clean
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import StdEnv
|
||||
|
||||
compare a b
|
||||
| a < b = "A is less than B"
|
||||
| a > b = "A is more than B"
|
||||
| a == b = "A equals B"
|
||||
|
||||
Start world
|
||||
# (console, world) = stdio world
|
||||
(_, a, console) = freadi console
|
||||
(_, b, console) = freadi console
|
||||
= compare a b
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Function Compare(a, b)
|
||||
IF a < b
|
||||
? "A is less than B"
|
||||
ELSEIF a > b
|
||||
? "A is more than B"
|
||||
ELSE
|
||||
? "A equals B"
|
||||
ENDIF
|
||||
Return Nil
|
||||
6
Task/Integer-comparison/Clojure/integer-comparison.clj
Normal file
6
Task/Integer-comparison/Clojure/integer-comparison.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(let [[a b] (repeatedly read)]
|
||||
(doseq [[op string] [[< "less than"]
|
||||
[> "greater than"]
|
||||
[= "equal to"]]]
|
||||
(when (op a b)
|
||||
(println (str a " is " string " " b)))))
|
||||
24
Task/Integer-comparison/ColdFusion/integer-comparison-1.cfm
Normal file
24
Task/Integer-comparison/ColdFusion/integer-comparison-1.cfm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<cffunction name="CompareInteger">
|
||||
<cfargument name="Integer1" type="numeric">
|
||||
<cfargument name="Integer2" type="numeric">
|
||||
<cfset VARIABLES.Result = "" >
|
||||
<cfif ARGUMENTS.Integer1 LT ARGUMENTS.Integer2 >
|
||||
<cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is less than " & ARGUMENTS.Integer2 & ")" >
|
||||
</cfif>
|
||||
<cfif ARGUMENTS.Integer1 LTE ARGUMENTS.Integer2 >
|
||||
<cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is less than or equal to " & ARGUMENTS.Integer2 & ")" >
|
||||
</cfif>
|
||||
<cfif ARGUMENTS.Integer1 GT ARGUMENTS.Integer2 >
|
||||
<cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is greater than " & ARGUMENTS.Integer2 & ")" >
|
||||
</cfif>
|
||||
<cfif ARGUMENTS.Integer1 GTE ARGUMENTS.Integer2 >
|
||||
<cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is greater than or equal to " & ARGUMENTS.Integer2 & ")" >
|
||||
</cfif>
|
||||
<cfif ARGUMENTS.Integer1 EQ ARGUMENTS.Integer2 >
|
||||
<cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is equal to " & ARGUMENTS.Integer2 & ")" >
|
||||
</cfif>
|
||||
<cfif ARGUMENTS.Integer1 NEQ ARGUMENTS.Integer2 >
|
||||
<cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is not equal to " & ARGUMENTS.Integer2 & ")" >
|
||||
</cfif>
|
||||
<cfreturn VARIABLES.Result >
|
||||
</cffunction>
|
||||
24
Task/Integer-comparison/ColdFusion/integer-comparison-2.cfm
Normal file
24
Task/Integer-comparison/ColdFusion/integer-comparison-2.cfm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<cfscript>
|
||||
function CompareInteger( Integer1, Integer2 ) {
|
||||
VARIABLES.Result = "";
|
||||
if ( ARGUMENTS.Integer1 LT ARGUMENTS.Integer2 ) {
|
||||
VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is less than " & ARGUMENTS.Integer2 & ")";
|
||||
}
|
||||
if ( ARGUMENTS.Integer1 LTE ARGUMENTS.Integer2 ) {
|
||||
VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is less than or equal to " & ARGUMENTS.Integer2 & ")";
|
||||
}
|
||||
if ( ARGUMENTS.Integer1 GT ARGUMENTS.Integer2 ) {
|
||||
VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is greater than " & ARGUMENTS.Integer2 & ")";
|
||||
}
|
||||
if ( ARGUMENTS.Integer1 GTE ARGUMENTS.Integer2 ) {
|
||||
VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is greater than or equal to " & ARGUMENTS.Integer2 & ")";
|
||||
}
|
||||
if ( ARGUMENTS.Integer1 EQ ARGUMENTS.Integer2 ) {
|
||||
VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is equal to " & ARGUMENTS.Integer2 & ")";
|
||||
}
|
||||
if ( ARGUMENTS.Integer1 NEQ ARGUMENTS.Integer2 ) {
|
||||
VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is not equal to " & ARGUMENTS.Integer2 & ")";
|
||||
}
|
||||
return VARIABLES.Result;
|
||||
}
|
||||
</cfscript>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
(let ((a (read *standard-input*))
|
||||
(b (read *standard-input*)))
|
||||
(cond
|
||||
((not (numberp a)) (format t "~A is not a number." a))
|
||||
((not (numberp b)) (format t "~A is not a number." b))
|
||||
((< a b) (format t "~A is less than ~A." a b))
|
||||
((> a b) (format t "~A is greater than ~A." a b))
|
||||
((= a b) (format t "~A is equal to ~A." a b))
|
||||
(t (format t "Cannot determine relevance between ~A and ~B!" a b)))))
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
(defun compare-integers ()
|
||||
(let ((a (read *standard-input*))
|
||||
(b (read *standard-input*)))
|
||||
(cond
|
||||
((not (numberp a)) (format t "~A is not a number." a))
|
||||
((not (numberp b)) (format t "~A is not a number." b))
|
||||
((< a b) (format t "~A is less than ~A." a b))
|
||||
((> a b) (format t "~A is greater than ~A." a b))
|
||||
((= a b) (format t "~A is equal to ~A." a b))
|
||||
(t (format t "Cannot determine relevance between ~A and ~B!" a b)))))
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
start: STP ; get input
|
||||
|
||||
x: NOP
|
||||
y: NOP
|
||||
|
||||
LDA x
|
||||
SUB y
|
||||
BRZ start ; x=y, A=0
|
||||
|
||||
loop: LDA x
|
||||
SUB one
|
||||
BRZ x<y
|
||||
STA x
|
||||
|
||||
LDA y
|
||||
SUB one
|
||||
BRZ x>y
|
||||
STA y
|
||||
|
||||
JMP loop
|
||||
|
||||
x>y: LDA one ; A := 1
|
||||
JMP start
|
||||
|
||||
x<y: SUB one ; A := 0-1
|
||||
JMP start
|
||||
|
||||
one: 1
|
||||
18
Task/Integer-comparison/D/integer-comparison.d
Normal file
18
Task/Integer-comparison/D/integer-comparison.d
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
void main() {
|
||||
import std.stdio, std.conv, std.string;
|
||||
|
||||
int a = 10, b = 20;
|
||||
try {
|
||||
a = readln.strip.to!int;
|
||||
b = readln.strip.to!int;
|
||||
} catch (StdioException) {}
|
||||
|
||||
if (a < b)
|
||||
writeln(a, " is less than ", b);
|
||||
|
||||
if (a == b)
|
||||
writeln(a, " is equal to ", b);
|
||||
|
||||
if (a > b)
|
||||
writeln(a, " is greater than ", b);
|
||||
}
|
||||
5
Task/Integer-comparison/DCL/integer-comparison.dcl
Normal file
5
Task/Integer-comparison/DCL/integer-comparison.dcl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$ inquire a "Please provide an integer"
|
||||
$ inquire b "Please provide another"
|
||||
$ if a .lt. b then $ write sys$output "the first integer is less"
|
||||
$ if a .eq. b then $ write sys$output "the integers have the same value"
|
||||
$ if a .gt. b then $ write sys$output "the first integer is greater"
|
||||
7
Task/Integer-comparison/Dc/integer-comparison.dc
Normal file
7
Task/Integer-comparison/Dc/integer-comparison.dc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[Use _ (underscore) as negative sign for numbers.]P []pP
|
||||
[Enter two numbers to compare: ]P
|
||||
? sbsa
|
||||
[[greater than]]sp lb la >p
|
||||
[ [less than]]sp lb la <p
|
||||
[ [equal to]]sp lb la =p
|
||||
la n [ is ]P P [ ]P lbn []pP
|
||||
12
Task/Integer-comparison/Delphi/integer-comparison.delphi
Normal file
12
Task/Integer-comparison/Delphi/integer-comparison.delphi
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
program IntegerCompare;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
var
|
||||
a, b: Integer;
|
||||
begin
|
||||
Readln(a, 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.
|
||||
9
Task/Integer-comparison/Draco/integer-comparison.draco
Normal file
9
Task/Integer-comparison/Draco/integer-comparison.draco
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
proc nonrec main() void:
|
||||
int a, b;
|
||||
write("Please enter two integers: ");
|
||||
read(a, b);
|
||||
if a<b then writeln(a, " < ", b)
|
||||
elif a=b then writeln(a, " = ", b)
|
||||
elif a>b then writeln(a, " > ", b)
|
||||
fi
|
||||
corp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
func compare(a, b) {
|
||||
if a < b {
|
||||
"A is less than B"
|
||||
} else if a > b {
|
||||
"A is more than B"
|
||||
} else {
|
||||
"A equals B"
|
||||
}
|
||||
}
|
||||
6
Task/Integer-comparison/E/integer-comparison.e
Normal file
6
Task/Integer-comparison/E/integer-comparison.e
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
def compare(a :int, b :int) {
|
||||
println(if (a < b) { `$a < $b` } \
|
||||
else if (a <=> b) { `$a = $b` } \
|
||||
else if (a > b) { `$a > $b` } \
|
||||
else { `You're calling that an integer?` })
|
||||
}
|
||||
9
Task/Integer-comparison/ECL/integer-comparison.ecl
Normal file
9
Task/Integer-comparison/ECL/integer-comparison.ecl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
CompareThem(INTEGER A,INTEGER B) := FUNCTION
|
||||
Result := A <=> B;
|
||||
STRING ResultText := CASE (Result,1 => 'is greater than', 0 => 'is equal to','is less than');
|
||||
RETURN A + ' ' + TRIM(ResultText) + ' ' + B;
|
||||
END;
|
||||
|
||||
CompareThem(1,2); //Shows "1 is less than 2"
|
||||
CompareThem(2,2); //Shows "2 is equal to 2"
|
||||
CompareThem(2,1); //Shows "2 is greater than 1"
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
[ Integer comparison
|
||||
==================
|
||||
|
||||
A program for the EDSAC
|
||||
|
||||
Illustrates the use of the E
|
||||
(branch on accumulator sign
|
||||
bit clear) and G (branch on
|
||||
accumulator sign bit set)
|
||||
orders
|
||||
|
||||
The integers to be tested, x
|
||||
and y, should be stored in
|
||||
addresses 13@ and 14@
|
||||
|
||||
Output: the program causes the
|
||||
machine to print
|
||||
'+' if x > y,
|
||||
'=' if x = y,
|
||||
'-' if x < y.
|
||||
|
||||
Works with Initial Orders 2 ]
|
||||
|
||||
T56K [ load point ]
|
||||
GK [ base address ]
|
||||
|
||||
O15@ [ figure shift ]
|
||||
|
||||
A13@ [ a = x ]
|
||||
S14@ [ a -= y ]
|
||||
G10@ [ if a<0 go to 10 ]
|
||||
|
||||
S12@ [ a -= 1 ]
|
||||
E8@ [ if a>=0 go to 8 ]
|
||||
|
||||
O17@ [ write '=' ]
|
||||
ZF [ halt ]
|
||||
|
||||
[ 8 ] O16@ [ write '+' ]
|
||||
ZF [ halt ]
|
||||
|
||||
[ 10 ] O18@ [ write '-' ]
|
||||
ZF [ halt ]
|
||||
|
||||
[ 12 ] P0D [ const: 1 ]
|
||||
|
||||
[ 13 ] P16D [ x = 37 ]
|
||||
[ 14 ] P14F [ y = 28 ]
|
||||
|
||||
[ 15 ] #F [ figure shift ]
|
||||
[ 16 ] ZF [ + character ]
|
||||
[ 17 ] VF [ = character ]
|
||||
[ 18 ] AF [ - character ]
|
||||
|
||||
EZPF [ begin execution ]
|
||||
16
Task/Integer-comparison/EMal/integer-comparison.emal
Normal file
16
Task/Integer-comparison/EMal/integer-comparison.emal
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
fun main = int by List args
|
||||
int a, b
|
||||
if args.length > 1
|
||||
a = int!args[0]
|
||||
b = int!args[1]
|
||||
else
|
||||
a = ask(int, "Enter the first integer ")
|
||||
b = ask(int, "Enter the second integer ")
|
||||
end
|
||||
writeLine("=== a <> b is " + (a <> b) + " ===")
|
||||
if a < b do writeLine(a + " < " + b) end
|
||||
if a == b do writeLine(a + " == " + b) end
|
||||
if a > b do writeLine(a + " > " + b) end
|
||||
return 0
|
||||
end
|
||||
exit main(Runtime.args)
|
||||
11
Task/Integer-comparison/EasyLang/integer-comparison.easy
Normal file
11
Task/Integer-comparison/EasyLang/integer-comparison.easy
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
a = number input
|
||||
b = number input
|
||||
if a < b
|
||||
print "less"
|
||||
.
|
||||
if a = b
|
||||
print "equal"
|
||||
.
|
||||
if a > b
|
||||
print "greater"
|
||||
.
|
||||
29
Task/Integer-comparison/Efene/integer-comparison.efene
Normal file
29
Task/Integer-comparison/Efene/integer-comparison.efene
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
compare = fn (A, B) {
|
||||
if A == B {
|
||||
io.format("~p equals ~p~n", [A, B])
|
||||
}
|
||||
else {
|
||||
ok
|
||||
}
|
||||
|
||||
if A < B {
|
||||
io.format("~p is less than ~p~n", [A, B])
|
||||
}
|
||||
else {
|
||||
ok
|
||||
}
|
||||
|
||||
if A > B {
|
||||
io.format("~p is greater than ~p~n", [A, B])
|
||||
}
|
||||
else {
|
||||
ok
|
||||
}
|
||||
}
|
||||
|
||||
@public
|
||||
run = fn () {
|
||||
compare(5, 5)
|
||||
compare(6, 5)
|
||||
compare(4, 5)
|
||||
}
|
||||
30
Task/Integer-comparison/Eiffel/integer-comparison.e
Normal file
30
Task/Integer-comparison/Eiffel/integer-comparison.e
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
class
|
||||
APPLICATION
|
||||
inherit
|
||||
ARGUMENTS
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
local
|
||||
i, j: INTEGER_32
|
||||
do
|
||||
io.read_integer_32
|
||||
i := io.last_integer_32
|
||||
|
||||
io.read_integer_32
|
||||
j := io.last_integer_32
|
||||
|
||||
if i < j then
|
||||
print("first is less than second%N")
|
||||
end
|
||||
if i = j then
|
||||
print("first is equal to the second%N")
|
||||
end
|
||||
if i > j then
|
||||
print("first is greater than second%N")
|
||||
end
|
||||
end
|
||||
end
|
||||
16
Task/Integer-comparison/Elena/integer-comparison.elena
Normal file
16
Task/Integer-comparison/Elena/integer-comparison.elena
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import extensions;
|
||||
|
||||
public program()
|
||||
{
|
||||
var a := console.readLine().toInt();
|
||||
var b := console.readLine().toInt();
|
||||
|
||||
if (a < b)
|
||||
{ console.printLine(a," is less than ",b) };
|
||||
|
||||
if (a == b)
|
||||
{ console.printLine(a," equals ",b) };
|
||||
|
||||
if (a > b)
|
||||
{ console.printLine(a," is greater than ",b) }
|
||||
}
|
||||
11
Task/Integer-comparison/Elixir/integer-comparison.elixir
Normal file
11
Task/Integer-comparison/Elixir/integer-comparison.elixir
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{a,_} = IO.gets("Enter your first integer: ") |> Integer.parse
|
||||
{b,_} = IO.gets("Enter your second integer: ") |> Integer.parse
|
||||
|
||||
cond do
|
||||
a < b ->
|
||||
IO.puts "#{a} is less than #{b}"
|
||||
a > b ->
|
||||
IO.puts "#{a} is greater than #{b}"
|
||||
a == b ->
|
||||
IO.puts "#{a} is equal to #{b}"
|
||||
end
|
||||
7
Task/Integer-comparison/Emacs-Lisp/integer-comparison.l
Normal file
7
Task/Integer-comparison/Emacs-Lisp/integer-comparison.l
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(defun integer-comparison (a b)
|
||||
"Compare A to B and print the outcome in the message buffer."
|
||||
(interactive "nFirst integer ⇒\nnSecond integer ⇒")
|
||||
(cond
|
||||
((< a b) (message "%d is less than %d." a b))
|
||||
((> a b) (message "%d is greater than %d." a b))
|
||||
((= a b) (message "%d is equal to %d." a b))))
|
||||
17
Task/Integer-comparison/Erlang/integer-comparison.erl
Normal file
17
Task/Integer-comparison/Erlang/integer-comparison.erl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
main() ->
|
||||
{ok, [N]} = io:fread("First integer: ", "~d"),
|
||||
{ok, [M]} = io:fread("First integer: ", "~d"),
|
||||
if
|
||||
N < M ->
|
||||
io:format("~b is less than ~b~n",[N,M]);
|
||||
N > M ->
|
||||
io:format("~b is greater than ~b~n",[N,M]);
|
||||
N == M ->
|
||||
io:format("~b is equal to ~b~n",[N,M])
|
||||
end.
|
||||
if
|
||||
N =< M ->
|
||||
io:format("~b is less than or equal to ~b~n",[N,M]);
|
||||
N >= M ->
|
||||
io:format("~b is greater than or equal to ~b~n",[N,M])
|
||||
end.
|
||||
15
Task/Integer-comparison/Euphoria/integer-comparison.euphoria
Normal file
15
Task/Integer-comparison/Euphoria/integer-comparison.euphoria
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
include get.e
|
||||
|
||||
integer a,b
|
||||
a = floor(prompt_number("a = ",{}))
|
||||
b = floor(prompt_number("b = ",{}))
|
||||
|
||||
puts(1,"a is ")
|
||||
if a < b then
|
||||
puts(1,"less then")
|
||||
elsif a = b then
|
||||
puts(1,"equal to")
|
||||
elsif a > b then
|
||||
puts(1,"grater then")
|
||||
end if
|
||||
puts(1," b")
|
||||
1
Task/Integer-comparison/Excel/integer-comparison-1.excel
Normal file
1
Task/Integer-comparison/Excel/integer-comparison-1.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=IF($A1>$B1;concatenate($A1;" is greater than ";$B1);IF($A1<$B1;concatenate($A1;" is smaller than ";$B1);concatenate($A1;" is equal to ";$B1)))
|
||||
1
Task/Integer-comparison/Excel/integer-comparison-2.excel
Normal file
1
Task/Integer-comparison/Excel/integer-comparison-2.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=IF($A1>$B1,concatenate($A1," is greater than ",$B1),IF($A1<$B1,concatenate($A1," is smaller than ",$B1),concatenate($A1," is equal to ",$B1)))
|
||||
8
Task/Integer-comparison/F-Sharp/integer-comparison.fs
Normal file
8
Task/Integer-comparison/F-Sharp/integer-comparison.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
let compare_ints a b =
|
||||
let r =
|
||||
match a with
|
||||
| x when x < b -> -1, printfn "%d is less than %d" x b
|
||||
| x when x = b -> 0, printfn "%d is equal to %d" x b
|
||||
| x when x > b -> 1, printfn "%d is greater than %d" x b
|
||||
| x -> 0, printf "default condition (not reached)"
|
||||
fst r
|
||||
4
Task/Integer-comparison/FALSE/integer-comparison.false
Normal file
4
Task/Integer-comparison/FALSE/integer-comparison.false
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
^^ \$@$@$@$@\
|
||||
>[\$," is greater than "\$,]?
|
||||
\>[\$," is less than "\$,]?
|
||||
=["characters are equal"]?
|
||||
5
Task/Integer-comparison/Factor/integer-comparison.factor
Normal file
5
Task/Integer-comparison/Factor/integer-comparison.factor
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
: example ( -- )
|
||||
readln readln [ string>number ] bi@
|
||||
[ > [ "A > B" print ] when ]
|
||||
[ < [ "A < B" print ] when ]
|
||||
[ = [ "A = B" print ] when ] 2tri ;
|
||||
22
Task/Integer-comparison/Fantom/integer-comparison.fantom
Normal file
22
Task/Integer-comparison/Fantom/integer-comparison.fantom
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
try
|
||||
{
|
||||
Env.cur.out.print ("Enter number 1: ").flush
|
||||
num1 := Env.cur.in.readLine.toInt
|
||||
Env.cur.out.print ("Enter number 2: ").flush
|
||||
num2 := Env.cur.in.readLine.toInt
|
||||
|
||||
if (num1 < num2)
|
||||
echo ("$num1 is smaller than $num2")
|
||||
else if (num1 == num2)
|
||||
echo ("$num1 is equal to $num2")
|
||||
else if (num1 > num2)
|
||||
echo ("$num1 is greater than $num2")
|
||||
}
|
||||
catch (Err e)
|
||||
echo ("You must enter two integers")
|
||||
}
|
||||
}
|
||||
7
Task/Integer-comparison/Fermat/integer-comparison.fermat
Normal file
7
Task/Integer-comparison/Fermat/integer-comparison.fermat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Func Compare =
|
||||
?a;
|
||||
?b;
|
||||
if a=b then !'Equal' fi;
|
||||
if a<b then !'Less than' fi;
|
||||
if a>b then !'Greater than' fi;
|
||||
.;
|
||||
13
Task/Integer-comparison/Fish/integer-comparison.fish
Normal file
13
Task/Integer-comparison/Fish/integer-comparison.fish
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
l2=?vv ~< v o<
|
||||
v <>l?^"Please pre-populate the stack with the two integers."ar>l?^;
|
||||
\$:@@:@)?v v ;oanv!!!?<
|
||||
>$n" is greater than "{r>ol1=^
|
||||
/ <
|
||||
\$:@@:@=?v v ;oanv!!!?<
|
||||
>$n" is equal to "{r>ol1=^
|
||||
/ <
|
||||
\$:@@:@(?v v ;oanv!!!?<
|
||||
>$n" is smaller than "{r>ol1=^
|
||||
> v
|
||||
/oo". "nooooo" and "n$< v o<
|
||||
>"They're not equal, not greater than and not smaller than eachother... strange."ar>l?^;
|
||||
4
Task/Integer-comparison/Forth/integer-comparison.fth
Normal file
4
Task/Integer-comparison/Forth/integer-comparison.fth
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
: compare-integers ( a b -- )
|
||||
2dup < if ." a is less than b" then
|
||||
2dup > if ." a is greater than b" then
|
||||
= if ." a is equal to b" then ;
|
||||
17
Task/Integer-comparison/Fortran/integer-comparison-1.f
Normal file
17
Task/Integer-comparison/Fortran/integer-comparison-1.f
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
program arithif
|
||||
integer a, b
|
||||
|
||||
c fortran 77 I/O statements, for simplicity
|
||||
read(*,*) a, b
|
||||
|
||||
if ( a - b ) 10, 20, 30
|
||||
10 write(*,*) a, ' is less than ', b
|
||||
goto 40
|
||||
|
||||
20 write(*,*) a, ' is equal to ', b
|
||||
goto 40
|
||||
|
||||
30 write(*,*) a, ' is greater than ', b
|
||||
40 continue
|
||||
|
||||
end
|
||||
9
Task/Integer-comparison/Fortran/integer-comparison-2.f
Normal file
9
Task/Integer-comparison/Fortran/integer-comparison-2.f
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
program compare
|
||||
integer a, b
|
||||
c fortran 77 I/O statements, for simplicity
|
||||
read(*,*) a, b
|
||||
|
||||
if (a .lt. b) write(*, *) a, ' is less than ', b
|
||||
if (a .eq. b) write(*, *) a, ' is equal to ', b
|
||||
if (a .gt. b) write(*, *) a, ' is greater than ', b
|
||||
end
|
||||
13
Task/Integer-comparison/Fortran/integer-comparison-3.f
Normal file
13
Task/Integer-comparison/Fortran/integer-comparison-3.f
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
program compare
|
||||
integer a, b
|
||||
read(*,*) a, b
|
||||
|
||||
if (a .lt. b) then
|
||||
write(*, *) a, ' is less than ', b
|
||||
else if (a .eq. b) then
|
||||
write(*, *) a, ' is equal to ', b
|
||||
else if (a .gt. b) then
|
||||
write(*, *) a, ' is greater than ', b
|
||||
end if
|
||||
|
||||
end
|
||||
13
Task/Integer-comparison/Fortran/integer-comparison-4.f
Normal file
13
Task/Integer-comparison/Fortran/integer-comparison-4.f
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
program compare
|
||||
integer :: a, b
|
||||
read(*,*) a, b
|
||||
|
||||
if (a < b) then
|
||||
write(*, *) a, ' is less than ', b
|
||||
else if (a == b) then
|
||||
write(*, *) a, ' is equal to ', b
|
||||
else if (a > b) then
|
||||
write(*, *) a, ' is greater than ', b
|
||||
end if
|
||||
|
||||
end program compare
|
||||
20
Task/Integer-comparison/FreeBASIC/integer-comparison.basic
Normal file
20
Task/Integer-comparison/FreeBASIC/integer-comparison.basic
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim As Integer x, y
|
||||
Input "Please enter two integers, separated by a comma : ", x , y
|
||||
|
||||
If x < y Then
|
||||
Print x; " is less than "; y
|
||||
End If
|
||||
|
||||
If x = y Then
|
||||
Print x; " is equal to "; y
|
||||
End If
|
||||
|
||||
If x > y Then
|
||||
Print x; " is greater than "; y
|
||||
End If
|
||||
|
||||
Print
|
||||
Print "Press any key to exit"
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
read a
|
||||
read b
|
||||
|
||||
if test $a -gt $b
|
||||
echo Greater
|
||||
else if test $a -lt $b
|
||||
echo Less
|
||||
else if test $a -eq $b
|
||||
echo Equal
|
||||
end
|
||||
7
Task/Integer-comparison/Frink/integer-comparison.frink
Normal file
7
Task/Integer-comparison/Frink/integer-comparison.frink
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[a,b] = eval[input["Enter numbers",["a","b"]]]
|
||||
if a<b
|
||||
println["$a < $b"]
|
||||
if a==b
|
||||
println["$a == $b"]
|
||||
if a>b
|
||||
println["$a > $b"]
|
||||
8
Task/Integer-comparison/FunL/integer-comparison.funl
Normal file
8
Task/Integer-comparison/FunL/integer-comparison.funl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import console.readInt
|
||||
|
||||
a = readInt()
|
||||
b = readInt()
|
||||
|
||||
val (_, c) = [((<), 'less than'), ((==), 'equal to'), ((>), 'greater than')].find( (compare, _) -> compare(a, b) ).get()
|
||||
|
||||
println( "$a is $c $b." )
|
||||
49
Task/Integer-comparison/FutureBasic/integer-comparison.basic
Normal file
49
Task/Integer-comparison/FutureBasic/integer-comparison.basic
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
_window = 1
|
||||
begin enum 1
|
||||
_integer1Fld
|
||||
_integer2Fld
|
||||
_compareBtn
|
||||
_messageLabel
|
||||
end enum
|
||||
|
||||
local fn BuildWindow
|
||||
window _window, @"Integer Comparison", (0,0,356,85)
|
||||
|
||||
textfield _integer1Fld,,, (20,44,112,21)
|
||||
TextFieldSetPlaceholderString( _integer1Fld, @"Integer 1" )
|
||||
|
||||
textfield _integer2Fld,,, (140,44,112,21)
|
||||
TextFieldSetPlaceholderString( _integer2Fld, @"Integer 2" )
|
||||
|
||||
button _compareBtn,,, @"Compare", (253,38,90,32)
|
||||
|
||||
textlabel _messageLabel,, (18,20,320,16)
|
||||
ControlSetAlignment( _messageLabel, NSTextAlignmentCenter )
|
||||
end fn
|
||||
|
||||
local fn DoDialog( ev as long, tag as long )
|
||||
long int1, int2
|
||||
|
||||
select ( ev )
|
||||
case _btnClick
|
||||
select ( tag )
|
||||
case _compareBtn
|
||||
int1 = fn ControlIntegerValue( _integer1Fld )
|
||||
int2 = fn ControlIntegerValue( _integer2Fld )
|
||||
|
||||
if ( int1 < int2 ) then textlabel _messageLabel, @"The first integer is less than the second integer."
|
||||
if ( int1 == int2 ) then textlabel _messageLabel, @"The first integer is equal to the second integer."
|
||||
if ( int1 > int2 ) then textlabel _messageLabel, @"The first integer is greater than the second integer."
|
||||
|
||||
end select
|
||||
|
||||
case _controlTextDidChange
|
||||
textlabel _messageLabel, @""
|
||||
end select
|
||||
end fn
|
||||
|
||||
fn BuildWindow
|
||||
|
||||
on dialog fn DoDialog
|
||||
|
||||
HandleEvents
|
||||
12
Task/Integer-comparison/Gambas/integer-comparison.gambas
Normal file
12
Task/Integer-comparison/Gambas/integer-comparison.gambas
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Public Sub Form_Open()
|
||||
Dim sIn As String = InputBox("Enter 2 integers seperated by a comma")
|
||||
Dim iFirst, iSecond As Integer
|
||||
|
||||
iFirst = Val(Split(sIn)[0])
|
||||
iSecond = Val(Split(sIn)[1])
|
||||
|
||||
If iFirst < iSecond Then Print iFirst & " is smaller than " & iSecond & gb.NewLine
|
||||
If iFirst > iSecond Then Print iFirst & " is greater than " & iSecond & gb.NewLine
|
||||
If iFirst = iSecond Then Print iFirst & " is equal to " & iSecond
|
||||
|
||||
End
|
||||
26
Task/Integer-comparison/Go/integer-comparison.go
Normal file
26
Task/Integer-comparison/Go/integer-comparison.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var n1, n2 int
|
||||
fmt.Print("enter number: ")
|
||||
if _, err := fmt.Scan(&n1); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Print("enter number: ")
|
||||
if _, err := fmt.Scan(&n2); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
switch {
|
||||
case n1 < n2:
|
||||
fmt.Println(n1, "less than", n2)
|
||||
case n1 == n2:
|
||||
fmt.Println(n1, "equal to", n2)
|
||||
case n1 > n2:
|
||||
fmt.Println(n1, "greater than", n2)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
def comparison = { a, b ->
|
||||
println "a ? b = ${a} ? ${b} = a ${a < b ? '<' : a > b ? '>' : a == b ? '==' : '?'} b"
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
comparison(2000,3)
|
||||
comparison(2000,300000)
|
||||
comparison(2000,2000)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
final rels = [ (-1) : '<', 0 : '==', 1 : '>' ].asImmutable()
|
||||
def comparisonSpaceship = { a, b ->
|
||||
println "a ? b = ${a} ? ${b} = a ${rels[a <=> b]} b"
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
comparison(2000,3)
|
||||
comparison(2000,300000)
|
||||
comparison(2000,2000)
|
||||
11
Task/Integer-comparison/Harbour/integer-comparison.harbour
Normal file
11
Task/Integer-comparison/Harbour/integer-comparison.harbour
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
PROCEDURE Compare( a, b )
|
||||
|
||||
IF a < b
|
||||
? "A is less than B"
|
||||
ELSEIF a > b
|
||||
? "A is more than B"
|
||||
ELSE
|
||||
? "A equals B"
|
||||
ENDIF
|
||||
|
||||
RETURN
|
||||
10
Task/Integer-comparison/Haskell/integer-comparison-1.hs
Normal file
10
Task/Integer-comparison/Haskell/integer-comparison-1.hs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
myCompare :: Integer -> Integer -> String
|
||||
myCompare a b
|
||||
| a < b = "A is less than B"
|
||||
| a > b = "A is greater than B"
|
||||
| a == b = "A equals B"
|
||||
|
||||
main = do
|
||||
a <- readLn
|
||||
b <- readLn
|
||||
putStrLn $ myCompare a b
|
||||
4
Task/Integer-comparison/Haskell/integer-comparison-2.hs
Normal file
4
Task/Integer-comparison/Haskell/integer-comparison-2.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
myCompare a b = case compare a b of
|
||||
LT -> "A is less than B"
|
||||
GT -> "A is greater than B"
|
||||
EQ -> "A equals B"
|
||||
14
Task/Integer-comparison/Hexiscript/integer-comparison.hexi
Normal file
14
Task/Integer-comparison/Hexiscript/integer-comparison.hexi
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
let a scan int
|
||||
let b scan int
|
||||
|
||||
if a < b
|
||||
println a + " is less than " + b
|
||||
endif
|
||||
|
||||
if a > b
|
||||
println a + " is greater than " + b
|
||||
endif
|
||||
|
||||
if a = b
|
||||
println a + " is equal to " + b
|
||||
endif
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue