Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Integer-comparison/Perl/integer-comparison-1.pl
Normal file
13
Task/Integer-comparison/Perl/integer-comparison-1.pl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
sub test_num {
|
||||
my $f = shift;
|
||||
my $s = shift;
|
||||
if ($f < $s){
|
||||
return -1; # returns -1 if $f is less than $s
|
||||
} elsif ($f > $s) {
|
||||
return 1; # returns 1 if $f is greater than $s
|
||||
} elsif ($f == $s) {
|
||||
# = operator is an assignment
|
||||
# == operator is a numeric comparison
|
||||
return 0; # returns 0 $f is equal to $s
|
||||
};
|
||||
};
|
||||
3
Task/Integer-comparison/Perl/integer-comparison-2.pl
Normal file
3
Task/Integer-comparison/Perl/integer-comparison-2.pl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
sub test_num {
|
||||
return $_[0] <=> $_[1];
|
||||
};
|
||||
5
Task/Integer-comparison/Perl/integer-comparison-3.pl
Normal file
5
Task/Integer-comparison/Perl/integer-comparison-3.pl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Get input, test and display
|
||||
print "Enter two integers: ";
|
||||
($x, $y) = split ' ', <>;
|
||||
print $x, (" is less than ", " is equal to ",
|
||||
" is greater than ")[test_num($x, $y) + 1], $y, "\n";
|
||||
Loading…
Add table
Add a link
Reference in a new issue