Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication1;
- import java.util.Scanner;
- public class JavaApplication1 {
- public static void main(String[] args) {
- int count=0;
- String in = "ab26cd72ef7g8h9ayush101gau";
- boolean previous = false;
- Scanner s = new Scanner(System.in);
- String input = s.nextLine();
- char characters[] = in.toCharArray();
- for(char a : characters){
- if(Character.isDigit(a)){
- if(previous == true){
- continue;
- }
- previous = true;
- count++;
- }
- else{
- previous = false;
- }
- }
- System.out.println(count);
- }
- }
Add Comment
Please, Sign In to add comment