Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Find the missing number of an array.

$
0
0
I'm trying to find out what numbers aren't in my array of a 100 numbers called 'stats'. I'm writing a method that would count the amount of times each number appears and place a counter on that number in a different array. So what I did in my method is set the index numbers that don't have any counts added to them to a string variable and have that output which numbers aren't in the array but I'm not sure whats wrong because it outputs a bunch of 0's.

public String Missing() {
    String theString = "";
    int count[] = new int[100];
    for (int i = 0; i!=100; i++){
        count[stats[i]]++;}
    for (int i2=0;i2!=100;i2++){
        if (count[i2]==0)
            theString+=count[i2];}
    return theString;}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>