fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void cutLog(String log) {
  6.  
  7. String logPieces[] = log.split("X");
  8.  
  9. int length =0;
  10. for (int i = 0; i < logPieces.length; i++) {
  11. if (logPieces[i].equals("")) {
  12.  
  13. } else {
  14. length ++;
  15. }
  16.  
  17. }
  18. System.out.println(length);
  19.  
  20. for (int i = 0; i < logPieces.length; i++) {
  21. if (logPieces[i].equals("")) {
  22.  
  23. } else {
  24. System.out.println(logPieces[i]);
  25. }
  26.  
  27. }
  28.  
  29. }
  30.  
  31. public static void main(String[] args) {
  32. int logLength;
  33. String log;
  34.  
  35. Scanner input = new Scanner(System.in);
  36. System.out.print("");
  37. logLength = input.nextInt();
  38. System.out.print("");
  39. Scanner input2 = new Scanner(System.in);
  40. log = input2.nextLine();
  41. System.out.print("");
  42.  
  43. cutLog(log);
  44.  
  45. }
  46.  
  47. }
Runtime error #stdin #stdout #stderr 0.09s 380672KB
stdin
4
XOOX
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.util.Scanner.nextLine(Scanner.java:1585)
	at Main.main(Main.java:40)