Answer the question
In order to leave comments, you need to log in
Where does 49 come from?
Says that the variable var = 49. Why is that?
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int number = scanner.nextInt();
int[] res = new int[10];
scanner.close();
for (int i = 1; i <= number; i++) {
String str = Integer.toString(i);
char[] n = str.toCharArray();
for (int j = 0; j < n.length; j++) {
System.out.print(n[j]);
int var = n[j];
res[var]++;
}
}
for (int i : res) {
System.out.print(i + " ");
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question