Problem Description Link
Algorithm:
This is a simple problem to solve this problem you need to read carefully.
However you can follow this technique to solve this problem.
1. At first you need 3 array for input string , reverse string and mirror string.
2. get input string
3. put value in reverse string array from input string . Last value of input string insert into
first value of reverse string and so on.
4. put value in mirror string from input string reverse order
when insert character in follow condition
if input string character is E then insert 3 and vise versa
if input string character is L then insert J and vise versa
if input string character is S then insert 2 and vise versa
if input string character is Z then insert 5 and vise versa
5. Check reverse string with input string if same put a falg rf=1;
6. for mirror check
Check mirror string with input string character by character
if get B,C,D,F,G,K,N,P,Q,R,4,6,7,9 in input string then this sting not mirror string
otherwise it is mirror so flag mp=1;
N.B: in this problem O and 0(zero) are same.
7. for print check
if(rp==0 && mp==0)
printf("%s -- is not a palindrome.\n\n",input);
else if(rp==1 && mp==0)
printf("%s -- is a regular palindrome.\n\n",input);
else if(rp==0 && mp==1)
printf("%s -- is a mirrored string.\n\n",input);
else if(rp==1 && mp==1)
printf("%s -- is a mirrored palindrome.\n\n",input);
Algorithm:
This is a simple problem to solve this problem you need to read carefully.
However you can follow this technique to solve this problem.
1. At first you need 3 array for input string , reverse string and mirror string.
2. get input string
3. put value in reverse string array from input string . Last value of input string insert into
first value of reverse string and so on.
4. put value in mirror string from input string reverse order
when insert character in follow condition
if input string character is E then insert 3 and vise versa
if input string character is L then insert J and vise versa
if input string character is S then insert 2 and vise versa
if input string character is Z then insert 5 and vise versa
5. Check reverse string with input string if same put a falg rf=1;
6. for mirror check
Check mirror string with input string character by character
if get B,C,D,F,G,K,N,P,Q,R,4,6,7,9 in input string then this sting not mirror string
otherwise it is mirror so flag mp=1;
N.B: in this problem O and 0(zero) are same.
7. for print check
if(rp==0 && mp==0)
printf("%s -- is not a palindrome.\n\n",input);
else if(rp==1 && mp==0)
printf("%s -- is a regular palindrome.\n\n",input);
else if(rp==0 && mp==1)
printf("%s -- is a mirrored string.\n\n",input);
else if(rp==1 && mp==1)
printf("%s -- is a mirrored palindrome.\n\n",input);
No comments:
Post a Comment
Write your comment - Share Knowledge and Experience