Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
how to find a symmetric substring in C language?
Posted
Comments
den2k88 7-Nov-14 6:03am    
That's a homework, I'd bet on it.

Anyway, what do you mean with "symmetric substring"? In which context? How is it made?

When you ask question be more specific, try things and tell us where you're stuck. We could even help with the reasoning behind, but this is not a code-for-free site.
Suzan Samivand 7-Nov-14 6:13am    
yh its a homework , i cant figure out how to do!
string like [bjsabjAPPLE3APPle] the [apple3apple] is symmetrical substr
den2k88 7-Nov-14 6:31am    
This is a clever (meaning pretty harsh) exercise. I think I have drafted a solution (not tested) but since it is a homework it is better to find the REASONING behind.

I assume this is a basic programming course, so I will use only basic instructions and will not focus on efficiency - it might complicate things a lot.

First thing, you are working with a string and searching substrings. So for the first thing you should scan the string char by char with a for cycle (let's say we use the variable i as counter).

Second thing, you obviously need to look subsequent characters in the string, so you will need a nested cycle (let's use variable j) that starst from the current value of the outer loop and scans until the end of the string, comparing the i-th carachet with the j-th.

Third, you need to find substrings, so you might need another nested cycle (let's use k) that when i-th and j-th characters are the same starts looking if the characters at the positions i+k and j+k are the same, and counts the equal characters.

Then, if you have more than 1 character you found the substrings. I left out most of the logic pointing out only the basic block-building reasoning behind the problem, the same reasoning I followed to draft the solution.

Think on this and try to write it down, see what goes wrong and do some trials, them eventually report us where you're stuck or wether you've benn successful.

Hope to be of help,
Denis
Suzan Samivand 7-Nov-14 6:38am    
thank u so much !!!!
ill let u know but im sure it works

1 solution

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A very quick search using your subject as the search term gave nearly 5 million hits: Google[^]

In future, please try to do at least basic research yourself, and not waste your time or ours.
 
Share this answer
 
Comments
Suzan Samivand 7-Nov-14 6:16am    
im sorry but ive already done that and no good came out of it !!!!! i need ur help on that !
OriginalGriff 7-Nov-14 6:24am    
Done what? Googled and not looked at any of the results?
Suzan Samivand 7-Nov-14 6:33am    
couldnt find what i was looking for ...
OriginalGriff 7-Nov-14 6:43am    
And what exactly were you looking for?
Suzan Samivand 7-Nov-14 6:56am    
i believe its solved now

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900