Advertisement
roronoa

count number of circles in number

Jun 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. /**
  6.  * Auto-generated code below aims at helping you parse
  7.  * the standard input according to the problem statement.
  8.  **/
  9. class Solution {
  10.  
  11.     public static void main(String args[]) {
  12.         Scanner in = new Scanner(System.in);
  13.         String s = in.nextLine();
  14.         s = s.replaceAll("[^0-9]","");
  15.         int[] tab = {1,0,0,0,0,0,1,0,2,1};
  16.         int sum = 0;
  17.         for(char c : s.toCharArray())    
  18.             sum += tab[c-'0'];
  19.         System.out.println(sum);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement