fork download
  1. class M{
  2. static String c(String s){
  3. String x[] = s.split("\\[\\?\\]"),
  4. r = "";
  5. int i = 0,
  6. l = x.length - 1;
  7. for (; i < l; r += x[i]
  8. + (x[i].length() < 1 | x[i].matches(".+[.!?] $")
  9. ? 65
  10. : 'a')
  11. + ("aeiouAEIOU".contains(x[++i].charAt(1)+"")
  12. ? "n"
  13. : ""));
  14. return r + x[l];
  15. }
  16.  
  17. public static void main(String[] a){
  18. System.out.println(c("Hello, this is [?] world!"));
  19. System.out.println(c("How about we build [?] big building. It will have [?] orange banana hanging out of [?] window."));
  20. System.out.println(c("[?] giant en le sky."));
  21. System.out.println(c("[?] yarn ball? [?] big one!"));
  22. System.out.println(c("[?] hour ago I met [?] European. "));
  23. System.out.println(c("Hey sir [Richard], how 'bout [?] cat?"));
  24. System.out.println(c("[?] dog is barking. [?] cat is scared!"));
  25. }
  26. }
Success #stdin #stdout 0.05s 711168KB
stdin
Standard input is empty
stdout
Hello, this is a world!
How about we build a big building. It will have an orange banana hanging out of a window.
A giant en le sky.
A yarn ball? A big one!
A hour ago I met an European. 
Hey sir [Richard], how 'bout a cat?
A dog is barking. A cat is scared!