954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please help

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

kentaki
Newbie Poster
5 posts since Jan 2009
Reputation Points: 6
Solved Threads: 0
 

does not seem to be a hard program to write?

Kevin Waite
Newbie Poster
2 posts since Jan 2009
Reputation Points: 10
Solved Threads: 1
 

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

Freaky_Chris
Master Poster
702 posts since Apr 2008
Reputation Points: 325
Solved Threads: 118
 

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

kentaki
Newbie Poster
5 posts since Jan 2009
Reputation Points: 6
Solved Threads: 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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

you are exactly right:D

kentaki
Newbie Poster
5 posts since Jan 2009
Reputation Points: 6
Solved Threads: 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..

kentaki
Newbie Poster
5 posts since Jan 2009
Reputation Points: 6
Solved Threads: 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

Freaky_Chris
Master Poster
702 posts since Apr 2008
Reputation Points: 325
Solved Threads: 118
 

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.

ronjustincase
Newbie Poster
12 posts since Dec 2008
Reputation Points: 11
Solved Threads: 2
 

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

Bladtman242
Junior Poster
176 posts since Dec 2008
Reputation Points: 18
Solved Threads: 4
 

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

MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
 

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

Freaky_Chris
Master Poster
702 posts since Apr 2008
Reputation Points: 325
Solved Threads: 118
 

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

Bladtman242
Junior Poster
176 posts since Dec 2008
Reputation Points: 18
Solved Threads: 4
 

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

kentaki
Newbie Poster
5 posts since Jan 2009
Reputation Points: 6
Solved Threads: 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

Bladtman242
Junior Poster
176 posts since Dec 2008
Reputation Points: 18
Solved Threads: 4
 
#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;
}
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You