Question is:

1-) You are given a set witl 10 elements.

X: { 23, 13, 25, 43, 45, 26, 10, 2, 27, 44 }
or you can choose any 10 elementsç it is not problem.

2-) You are asked to write a program which can generate subsets of X with specific number of elements.
your program's output should be like this:

X = { 23, 13, 25, 43, 45, 26, 10, 2, 27, 44 }
Enter the number of elements for subset generation : 9 (for example you entered 9 )
SUBSETS WITH 9 ELEMENTS
-----------------------------------
23 13 25 43 45 26 10 2 27
23 13 25 43 45 26 10 2 44
23 13 25 43 45 26 10 27 44
23 13 25 43 45 26 2 27 44
23 13 25 43 45 10 2 27 44
"
"
"

Fail.
8
Contributors
15
Replies
16
Views
8 Years
Discussion Span
Last Post by iamthwee

does not seem to be a hard program to write?

What exactly do you mean by subset? as in are you trying to list all the different permutations of the numbers?

subset is a mathematical term for example if you have a set contains 3 elements x:{a, b, c, }
so
{a} is a subset of X with 1 elements
{b} is subset of x with 1 elements
{c} is a subset of x with 1 elements
{a,b} is asubset of x with 2 element
{a,c} is a subset of x with 2 elements
{b,c} is a subset of x with 3 elements like this...
I want to write a program that list the subsets specificly .
thank you very much..

No one is going to write this program for you. You need to make an attempt, then when you get stuck, ask a specific question.

you are exactly right:D

if I was able to write this program I did not want help from people.

So where are your failed attempts, that was the point being made....we didnt say write it correctly then show it us...we said have a go and show us what you have and what it is you are having problems with

I am vehbi your c++ asistant. we gave you this homework for learning c++, i take your ip from admin and checking with the ones that enter lms. you will get 0 and a discipline investigation is strated because of plagarism.

^^ i believe now is the time say: OWNED! /\/[][]/3

Except I doubt his authority, due to lack of English skills. And receiving an IP from admin; why should you be given that, Ron?

My exact thoughts but hey if it gets him to do his own work in future lol

Ha ha, yeah okay. you´re proberbly right :-P

I fundamentally agree with you about his english skills. Really....
I will explain later...

Apart from that guys, he gives his name, how would he know the name of OT's teacher? and about the english, well; 1, not everyone in here live in the UK or the USA (I, for one, am scandinavian).
And a lot of programming tasks are outsourced to fx India due to their expertice and low salary demands ;-) I still think you are right, just saying

``````#include <stdio.h>

void printv ( int mask[], int n )
{
int i;
printf ( "{ " );
for ( i = 0; i < n; ++i )
printf ( "%d ", i + 1 );

printf ( "}" );
printf ( "\n" );
}

int next ( int mask[], int n )
{
int i;
for ( i = 0; ( i < n ) && mask[i]; ++i )

if ( i < n )
{
return 1;
}
return 0;
}

int main ( int argc, char *argv[] )
{
int n = 9;

int i;
for ( i = 0; i < n; ++i )

while ( next ( mask, n ) )

getchar();
return 0;
}``````