H
H
hellcaster2019-02-02 13:21:34
Java
hellcaster, 2019-02-02 13:21:34

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

1 answer(s)
1
1001001, 2019-02-02
@web_Developer_Victor

From here, int var = n[j];
if you want to continue your strange actions, do this
5c55751f52bbf708897892.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question