Results 1 to 2 of 2
  1. #1
    aufis is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Unhappy [HELP] bit string confusion

    Greetings..

    I am tasked to convert numbers to bit strings to identify the differences of sets
    my experimental Universal set is {1,2,3,4,5,6}. and my subset is {1,3,5}
    if my Universal Set's strings would be "111111" my subset would be "101010"
    for further explanation one means the element of the universal set is present to the sub set. zero means, that element of the universal set does not exist on the subset. This is my problem.
    universal is the number of element of the universal set. in my experiment this is 6.
    set1 is the number of element of the subset. in my experiment, it would be 3.
    set1str array would be the storage for the bit string of my subset.
    universe array is the universal set.
    num1 array is the subset.

    Java Code:
    int set1str[] = new int[universal];
    for(int i=0; i<set1; i++)
    {
    	for(int j=i; j<universal;j++)
    	{
    	if(universe[j]==num1[i])
    	{
    		System.out.print("1");
    		set1str[i] = 1;
    		j=universal;
    		
    	}
    	else
    		System.out.print("0");
    		set1str[i] = 0;
    	}
    	
    }
    base on my experimental sets,
    this code converts the bit string to 101001...
    because 1(universal set) and 1(subset) in the if statement would print "1"
    then end the nested loop.
    on 2(universal set) and 3(subset) in the if statement would print "0"
    on 3(universal set) and 3(subset) in the if statement would print "1"
    on 3(universal set) and 5(subset) in the if statement would print "0"
    on 4(universal set) and 5(subset) in the if statement would print "0"
    on 5(universal set) and 5(subset) in the if statement would print "1"
    then my code stops..
    i had an answer of 101001 which is wrong
    i should have 101010...

    can you please help me edit my codes?
    please?
    if this would be on the wrong section, i am sorry.., im just new here and because i made this code on eclipse, i posted it here on the eclipse section.

    please help me. :(
    :(
    :(
    Last edited by Fubarable; 03-07-2011 at 04:42 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Moderator actions:
    • Code tags added. To see how to do this yourself, please click on the link in my signature below.
    • Thread moved from Eclipse forum to the New to Java forum

Similar Threads

  1. object name confusion
    By mobosecomin in forum New To Java
    Replies: 4
    Last Post: 01-20-2011, 02:45 AM
  2. Confusion here @@' Help!
    By pleasurelyours in forum New To Java
    Replies: 7
    Last Post: 06-09-2010, 03:42 PM
  3. Boolean confusion
    By KM88 in forum New To Java
    Replies: 13
    Last Post: 11-02-2009, 12:44 PM
  4. confusion in paragraph
    By JavaJunkie in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-19-2009, 03:02 PM
  5. Tic Tac Toe confusion
    By jigglywiggly in forum New To Java
    Replies: 15
    Last Post: 04-12-2009, 01:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •