fork download
  1. class M{
  2. static String c(String[] a){
  3. a[0] = a[0].split("\\d")[0] + "] = {\b";
  4. for(String i : a){
  5. a[0] += i.split("= [{]*")[1];
  6. }
  7. return a[0].replace(";", ", ").replaceFirst("..$", "};");
  8. }
  9.  
  10. public static void main(String[] a){
  11. System.out.println(c(new String[]{ "spam eggs[10];", "eggs[0] = 0;", "eggs[1] = 4;",
  12. "eggs[2] = 8;", "eggs[3] = -3;", "eggs[4] = 3;", "eggs[5] = 7;", "eggs[6] = 888;",
  13. "eggs[7] = 555;", "eggs[8] = 0;", "eggs[9] = -2;" }));
  14. System.out.println(c(new String[]{ "char ans[2]", "ans[0] = 52;", "ans[1] = 50;" }));
  15. System.out.println(c(new String[]{ "blah_blah quux[1];", "quux[0] = 105;" }));
  16. }
  17. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
spam eggs[] = {0, 4, 8, -3, 3, 7, 888, 555, 0, -2};
char ans[] = {52, 50};
blah_blah quux[] = {105};