0

I have string in C-code where all char in string is unique. I want to get all substring from this string, exclude empty string and getting string. How can i do this?

For example: String: "12a" I need to get: '1', '2', 'a', "12", "1a", "2a".

P.S. in my problem, set represented by string set and subset represented by substrings.

  • We're not going to do your homework for you. Show what you've tried and we'll tell you where you went wrong. – Barmar Apr 25 '13 at 19:48
  • 2
    Hint: It's a *recursive* problem. – Robert Harvey Apr 25 '13 at 19:49
  • @RobertHarvey Not necessarily. You can do it iteratively with subsets. –  Apr 25 '13 at 19:52
  • To be more accurate, it's a problem that can be solved recursively. – Robert Harvey Apr 25 '13 at 19:52
  • @RobertHarvey Yes, that's precise. –  Apr 25 '13 at 19:53
  • 1
    Hint: an easy solution is to regard the string as a set, then generate all its possible subsets. A set with N elements has 2 ^ N subsets, which you can obtain by generating all the binary numbers with N digits, including an element in the subset if and only if the digit it corresponds to is 1. –  Apr 25 '13 at 20:01
  • you can use this [link](http://www.programmingsimplified.com/c/source-code/c-substring): – Nasif Imtiaz Ohi Apr 25 '13 at 20:47

0 Answers0