You are viewing a single comment's thread. Return to all comments →
can anyone explain whats wrong with my code? public class superString {
public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); int count = 0; for (int i = 0; i < s.length(); i++) { for (int j = 0; j <= s.length(); j++) { try { // System.out.println(s.substring(i,j)); int k = Integer.valueOf(s.substring(i, j)); if (k==0) { count++; } else if ((s.substring(i, j).startsWith("0"))) { count += 0; } else { if (k % 6 == 0) { count += 1; } } } catch (Exception e) { } } } System.out.println(count); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Super Six Substrings
You are viewing a single comment's thread. Return to all comments →
can anyone explain whats wrong with my code? public class superString {
}