As the title implies I'm having trouble writing a code that can do as asked. What I have is:
public static void main(String[] args) {
int[] runs = new int[24];
for(int i = 0; i < runs.length; i++) {
runs[i] = (int)(Math.random()*3 + 1);
int count = 1;
for (int j = i+1; j<i;j++) {
if (runs[i] == runs[j]) {
count++;
}
}
System.out.println(runs[i] + " " + count);
}
}
However, whenever I run my program, it will just list the randomly generated numbers and then a 1 next to them. Any help is appreciated, thank you!
Aucun commentaire:
Enregistrer un commentaire