union of two sets

This is a discussion on union of two sets within the C Programming forums, part of the General Programming Boards category; i have two sets which i assigned them in an array i want to have the union of two sets ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    34

    union of two sets

    i have two sets which i assigned them in an array
    i want to have the union of two sets in a new array
    can any one help

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    Sure, what's the actual problem - show some code.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    34
    Code:
    int i;
    int a[10],b[10],c[10];
    for(i=0;i<10;i++)
    scanf("&#37;d",&a[i]);
    for(i=0;i<10;i++)
    scanf("%d",&b[i]);
    now
    suppouse i entered 1,2,3 in a[0],a[1],a[2]
    and 4,5,6 in b[0],b[1],b[2] respectively
    i want 1,2,3,4,5,6 to be copied to c[0],c[1],c[2],c[3],c[4],c[5]
    i think i am clear with my question

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    Have you written a 'isMemberOfSet' function?

    If you have one of these, then writing union and intersection is just a matter of repeatedly calling that function in a loop and deciding what to do with the true/false answer.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem aligning floating point numbers
    By esbo in forum C Programming
    Replies: 4
    Last Post: 01-05-2009, 08:09 PM
  2. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. union of two sets
    By axon in forum C++ Programming
    Replies: 1
    Last Post: 12-04-2003, 03:18 PM
  5. Sorting a Union
    By andy in forum C Programming
    Replies: 4
    Last Post: 11-21-2001, 10:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21