View Code of Problem 50

    import java.util.Scanner;
    public class Main {
    		public static void main(String[] args) 
                {
    			Scanner scan = new Scanner(System.in);
    			String str = scan.nextLine();
                  boolean flag=false;
                  for(int i=0;i<str.length();i++)
                  {
                    char c=str.charAt(i);
                    if(c>='0'&&c<='9')
                    {
                      System.out.print(c);
                      flag=false;
                    }else
                    {
                      if(!flag){
                      System.out.print(c);
                        flag=true;}
                    }
                    
                  }
    			System.out.println();
    		}
    	}

Double click to view unformatted code.


Back to problem 50