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/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}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue