-2

I need help about a question FOLLOWİNG (please use the c++)
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
"
"
"

Comments
Fail.
"Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!", Grow Up!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8
Contributors
15
Replies
16
Views
8 Years
Discussion Span
Last Post by iamthwee
0

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..

0

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.

0

if I was able to write this program I did not want help from people.
secondly I had made lots of attempt myself but I had failed and I have only 27 hours to complete this program... thaks for your advice..

0

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

0

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.

0

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

0

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

0

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

0
#include <stdio.h> 

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

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

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

  if ( i < n )
  {
    mask[i] = 1;
    return 1;
  }
  return 0;
}

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

  int mask[200];

  int i;
  for ( i = 0; i < n; ++i )
    mask[i] = 0; 

  printv ( mask, n ); 

  while ( next ( mask, n ) )
    printv ( mask, n ); 

  getchar();
  return 0;
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.