Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class MyTest{
  4. static List<String> GetCombination(String[][] input){
  5. List<String> temp = new ArrayList<String>();
  6. List<String> result = new ArrayList<String>();
  7. result.add("");
  8.  
  9. for (String[] a : input){
  10. for (String s : a){
  11. for (String r : result){
  12. temp.add(s+r);
  13. }
  14. }
  15. result = new ArrayList<String>(temp);
  16. temp.clear();
  17. }
  18.  
  19. return result;
  20. }
  21.  
  22. public static void main(String[] args) {
  23. String[][] input = {
  24. { "a", "b", "c", "d", "e" },
  25. { "+", "-", "*", "/" },
  26. { "1", "2" },
  27. };
  28.  
  29. List<String> result = GetCombination(input);
  30. System.out.println(result);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement