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

Join 136,480 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,688 people online right now. 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
3 Jul, 2008 - 01: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
+Quote Post

gabehabe
RE: Recursion
3 Jul, 2008 - 01:48 PM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,539



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

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 offlineProfile CardPM
+Quote Post

international
RE: Recursion
3 Jul, 2008 - 02: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
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 06:36PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month