fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int wordCount=0;
  13. int maxwords =0;
  14. int i=0;
  15. String S="We test coders. Give us a try?";
  16. while(i<S.length()){
  17. if(S.charAt(i) == ' '){
  18. wordCount++;
  19. }else if(S.charAt(i)== '.' || S.charAt(i) == '?' || S.charAt(i)== '!'){
  20. wordCount++;
  21. if(wordCount > maxwords){
  22. maxwords= wordCount;
  23. }
  24. wordCount=0;
  25. }
  26. i++;
  27. }
  28. /*if(!(S.charAt(i-1)== '.' || S.charAt(i-1) == '?' || S.charAt(i-1)== '!')){
  29.  
  30. if(wordCount > maxwords){
  31. maxwords= wordCount;
  32. }
  33. }*/
  34. System.out.println(maxwords);
  35. }
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError:   File "prog.py", line 1
    /* package whatever; // don't place package name! */
    ^
SyntaxError: invalid syntax

stdout
Standard output is empty