Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String []args)
- {
- Scanner sc=new Scanner(System.in);
- String st;
- int result=0,length=0,i;
- char ch;
- st=sc.nextLine();
- for(i=0;i<st.length();i++)
- {
- ch=st.charAt(i);
- if(ch!=' ')
- {
- length=length+1;
- }
- else
- {
- result=Math.max(result,length);
- length=0;
- }
- }
- result=Math.max(result,length);
- System.out.print(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement