Welcome to Dream.In.Code
Click Here
Getting C++ Help is Easy!

Join 117,161 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 2,397 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



recursion

 
Reply to this topicStart new topic

recursion, recursive function that lists all the two-elemnt subsets of a given se

international
post 3 Jul, 2008 - 02:48 PM
Post #1


New D.I.C Head

*
Joined: 26 Jun, 2008
Posts: 4

CODE
#include<stdio.h>
#define max 25

void two_ele_subs(char *str);

int main()
{
    char str[max];
    
    printf("Enter your string: ");
    scanf("%s",str);
    two_ele_subs(str);
    
return 0;    
}

void two_ele_subs(char *str)
{
    int i,j;
    for(i=0;i < strlen(str)-1; i++)
        for(j=i+1;j < strlen(str); j++)
            printf("{%c,%c}\n",str[i],str[j]);
    
}



this function lists all the two-element subsets of a given set of letters.
I didn't find the solution using a recursive function.
thank u in advance
User is offlineProfile CardPM

Go to the top of the page


gabehabe
post 3 Jul, 2008 - 02:48 PM
Post #2


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 3,311



Thanked 67 times

Dream Kudos: 2075

Expert In: (X)HTML, CSS, Batch Scripting, C, C++

My Contributions


What specific problems are you having?

The only issue I see at a glance is that you are using strlen() without #include <string.h>
User is online!Profile CardPM

Go to the top of the page

international
post 3 Jul, 2008 - 03:21 PM
Post #3


New D.I.C Head

*
Joined: 26 Jun, 2008
Posts: 4

QUOTE(gabehabe @ 3 Jul, 2008 - 02:48 PM) *

What specific problems are you having?

The only issue I see at a glance is that you are using strlen() without #include <string.h>


THANK U.

but this is not my problem.I want to implement the same function but using recursion.
thank u in advance.
how can transform this function to a recursive function that has the same purpose.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 10/6/08 11:04AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month