Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public static void main(String []args)
  2. {
  3. Scanner sc=new Scanner(System.in);
  4. String st;
  5. int result=0,length=0,i;
  6. char ch;
  7. st=sc.nextLine();
  8. for(i=0;i<st.length();i++)
  9. {
  10. ch=st.charAt(i);
  11. if(ch!=' ')
  12. {
  13. length=length+1;
  14. }
  15. else
  16. {
  17. result=Math.max(result,length);
  18. length=0;
  19. }
  20. }
  21. result=Math.max(result,length);
  22. System.out.print(result);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement