Print("Please enter a string ");
$input_string = <STDIN>;
chop($input_string);
$rev_string = reverse($input_string);
if($input_string eq $rev_string){
print("The string is a palindrome");
}else{
print("The string is NOT a palindrome");
}
Check the script
1=0
cnt=1
tag=0
echo "Enter a String?"
read str
1 =`echo $str |wc -c`
1 =`expr $l - 1`
1h=`expr $l / 2`
while [ $cnt -le $lh ]
do
c1=`echo $str|cut -c$cnt`
c2=`echo $str|cut -c$l`
if [ $c1 != $c2 ]
then
cnt=$lh
tag=1
fi
cnt=`expr $cnt + 1`
=`expr $l - 1`
done
if [ $tag -eq 0 ]
then
echo "String is Palindrome"
else
echo ?String is not Palindrome?
fi
$input_string = <STDIN>;
chop($input_string);
$rev_string = reverse($input_string);
if($input_string eq $rev_string){
print("The string is a palindrome");
}else{
print("The string is NOT a palindrome");
}
Check the script
1=0
cnt=1
tag=0
echo "Enter a String?"
read str
1 =`echo $str |wc -c`
1 =`expr $l - 1`
1h=`expr $l / 2`
while [ $cnt -le $lh ]
do
c1=`echo $str|cut -c$cnt`
c2=`echo $str|cut -c$l`
if [ $c1 != $c2 ]
then
cnt=$lh
tag=1
fi
cnt=`expr $cnt + 1`
=`expr $l - 1`
done
if [ $tag -eq 0 ]
then
echo "String is Palindrome"
else
echo ?String is not Palindrome?
fi
No comments:
Post a Comment