Thread: Generating Subsets

  1. #1
    Registered User
    Join Date
    Dec 2014
    Posts
    7

    Generating Subsets

    I'm a beginner in C programming and I've got a task that can't finish it..

    I'm supposed to generate and print the subsets of a group that its size I should enter. Pointers are not allowed!!

    How am I supposed to do it?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > How am I supposed to do it?
    Well you start with pencil and paper, and make sure you understand the process.

    If you can't write out the steps on paper, you can't write a program to do the same thing.

    Start small.
    All the subsets of 1 element - that should be easy enough
    All the subsets of 2 elements
    All the subsets of 3 elements
    All the subsets of 4 elements (by now, you should be seeing a pattern emerging)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to print out all possible subsets using set.h?
    By mgy in forum C++ Programming
    Replies: 2
    Last Post: 05-12-2014, 11:11 AM
  2. Find all subsets with sum of x
    By mgracecar in forum C Programming
    Replies: 1
    Last Post: 10-20-2013, 02:43 PM
  3. How to do array subsets?
    By gormster in forum C Programming
    Replies: 5
    Last Post: 11-14-2007, 06:50 AM
  4. compute the subsets of a set
    By k_w_s_t_a_s in forum C Programming
    Replies: 4
    Last Post: 06-01-2003, 05:54 PM
  5. subsets
    By scottmanc in forum C++ Programming
    Replies: 7
    Last Post: 03-11-2003, 08:22 AM