jebril's Profile User Rating: -----

Reputation: -4 Dishonored
Group:
Members
Active Posts:
32 (0.04 per day)
Joined:
24-March 12
Profile Views:
535
Last Active:
User is offline Jun 07 2012 12:06 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   jebril has not set their status

Posts I've Made

  1. In Topic: always display 0

    Posted 7 Jun 2012

    View Postpbl, on 07 June 2012 - 10:30 AM, said:

    found = false; should be reset in all cases

    My bad I guess :)

    			if(found==false){
    				distinct[count++] = enter[i];
    				System.out.print(" > " + enter[i] + " ");
    			}
    			found = false; // <--------------------
    
    

    finally it works :) 10x u man :)
  2. In Topic: always display 0

    Posted 7 Jun 2012

    :helpsmilie: :helpsmilie: :helpsmilie: :helpsmilie: :helpsmilie:
  3. In Topic: always display 0

    Posted 7 Jun 2012

    View Postpbl, on 06 June 2012 - 02:11 PM, said:

    Works for me

    	public static void main(String[] args) {
    
    		int[] enter = {1,4,5,6,5,4,3,2,2,3,4,5};
    		int[] distinct = new int[enter.length];
    		int count=0;
    		boolean found=false;
    		for( int i=0 ; i<enter.length; i++){
    			for( int j=0; j<count;j++){
    				if(enter[i]==distinct[j]){
    					found=true;
    					break;
    				}
    			}
    			if(found==false){
    				distinct[count++]=enter[i];
    				System.out.print(" " + enter[i]);
    				found = false;
    
    			}
    		}
    	}
    
    

    but it doesn't show the number 2 and 3 :online2long: any more idea?
  4. In Topic: always display 0

    Posted 6 Jun 2012

    View Postmacosxnerd101, on 06 June 2012 - 01:40 PM, said:

    So if the element is 0, don't print it.

    and what the number 6?
  5. In Topic: always display 0

    Posted 6 Jun 2012

    View Postpbl, on 06 June 2012 - 01:00 PM, said:

    Your add to count++ should be done onece the loop is completed, not a each iteration
    and you have to reset found

    public class distinct {
         
             int count=0;
             boolean found=false;
             for( int i=0 ; i<enter.length; i++){
                 for( int j=0; j<count;j++){
                     if(enter[i]==distinct[j]){
                         found=true;
                         break;
                     }
                 }
                 if(found==false){
                   distinct[count++]=enter[i];
                 found = false;
                     
             }
         return distinct;
    }
         
    
    
    


    it still there is an error ! for example if i enter:
    Enter 10 integers: 1 2 3 4 2 1 6 3 1 2
    distinct are:
    1 2 3 4 0 0 0 0 0 0 <----- it dont put the 6!! any idea?

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.anarchyhome.wordpress.com

Friends

Comments

jebril has no profile comments yet. Why not say hello?