in reply to Palindrome Program without Reverse function
Try this!!!!
#!\\C:\\Perl\\bin\\perl -w my $name=<STDIN>; chomp($name); @arr=split(//,$name); $count=@arr; $num=0; #print $count; for ($i=0;$i<$count;$i++){ if ($arr[$i] eq $arr[$count-1]){ #print "$arr[$i] ===== $arr[$count]\n"; $count--; }else{ $num++; last; } } if ($num == 0){ print "Word is polindrome!!!"; }else{ print "Word is not a Polindrome!!!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Palindrome Program without Reverse function
by choroba (Cardinal) on Jul 16, 2015 at 13:27 UTC |