Wednesday, 23 November 2016

Find String Palindrome

Linux(String Palindrome)

echo "Palindrome Checking"
echo "~~~~~~~~~~ ~~~~~~~~"
echo "Enter The String"
read str
l=s{#str}
ll=`expr $l / 2`
j=$l
f=0
i=1
while test $i -le $ll
do
c1=`echo $str | cut -c $i`
c2=`echo $str | cut -c $j`
if test $c1 != $c2
then
f=1
fi
i=`expr $i + 1`
j=`expr $j - 1`
done
if test $f -eq 1
then
echo "Given String Is not Palindrome"
else
echo "Given String Is Palindrome"
fi

No comments:

Post a Comment