HI , everyone can you please write a program for me , I have a set with 5 things in it thats line a={1,2,3,4,5} but it could be everything possible and there are subsets like b={1} c{1,2} d{1,2,4,5}
but I cant write the progam so if you can write a program easily with no use of vector :D
think Like you have only this following tools in this program

#include <iostream>
#include <conio.h>

using namespace std;

void chap(int are [] ,int ja , int ad ) {
     for (int i=ja+1;i<5;i++) {
         for (int q=ad;q<=ja;q++)
             cout<<are[q]<<" ";
         cout<<are[i]<<endl;
     }
     if (!(ja==4)) chap(are,ja+1,ad);   
     if (!(ja==4)) chap(are,ja+1,ad+1); 
     }  

int main() {
    int ar[5];
    for (int i=0;i<5;i++) {
        cin>>ar[i];

    }
    for (int i=0;i<5;i++) {
        cout<<ar[i]<<endl;

    }

    chap(ar,0,0);
    getch();

}

and sry , Im a little young for this things so sry for my silly question :D

LoL, Im so younger than that to get programming home work but I think I figured it out but its not the best way , a function that get two parameters , an array and an integer
the way is {1,-1,-1,-1,-1} calls another {1,1,-1,-1,-1} and goes until it finishes and get like this {1,5,5,5,5} and then goes to another that is {2,-1,-1,-1,-1} but the -1 wont be couted , but it still isnt the best way cause many subsets will be couted more than once , can Anyone help with that ?

@ kshahnazari

First thing : Give n elements set, how will you find out total number of subsets in it ?

Edited 4 Years Ago by np complete

This question has already been answered. Start a new discussion instead.