Advertisement
Guest User

royi

a guest
Oct 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. package test;
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. public class Elementary {
  8. // Don't place your source in a package
  9.  
  10. // Please name your class Main
  11. HashMap<Character, List<Character>> adding;
  12. HashMap<Character, List<Character>> reducing;
  13.  
  14. public static void main(String[] args) throws java.lang.Exception {
  15. Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
  16. int[] initValues = {0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0};
  17. char[][] data = {
  18. /*a*/{'/','/','+','/','/','/','+','/','/','/','/','+','+','/','/','/','/','+','+','+','+','/','/','/','/','/'},
  19. /*b*/{'/','/','/','-','/','/','-','+','+','-','+','-','-','/','/','/','-','/','/','-','/','/','/','-','/','-'},
  20. /*c*/{'/','/','/','/','/','+','-','/','/','-','/','/','/','+','+','/','-','/','+','-','+','/','/','-','/','-'},
  21. /*d*/{'/','+','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','+','/','/','/','/','/','+','/'},
  22. /*e*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','+','+','/','+','/','/','/','/','/'},
  23. /*f*/{'-','/','/','-','/','/','-','/','/','-','/','/','/','/','/','/','-','/','/','-','/','/','/','-','/','-'},
  24. /*g*/{'+','/','/','+','+','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  25. /*h*/{'-','/','/','-','/','+','/','/','/','-','/','-','-','/','+','/','-','-','+','-','/','/','/','-','/','-'},
  26. /*i*/{'-','/','/','-','-','/','-','/','/','-','/','-','-','+','/','/','-','/','/','-','/','/','/','-','/','-'},
  27. /*j*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  28. /*k*/{'-','/','/','-','-','/','-','/','/','-','/','-','-','/','/','/','-','/','/','-','/','/','/','-','/','-'},
  29. /*l*/{'+','/','/','/','/','/','/','/','+','/','/','/','/','/','/','/','/','+','/','/','+','+','/','/','/','/'},
  30. /*m*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  31. /*n*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  32. /*o*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  33. /*p*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  34. /*q*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  35. /*r*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  36. /*s*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  37. /*t*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  38. /*u*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  39. /*v*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  40. /*w*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  41. /*x*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  42. /*y*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'},
  43. /*z*/{'/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/','/'}};
  44.  
  45.  
  46. int n = in.nextInt();
  47. long cntr = 0;
  48. for (int t = 0; t < n; t++) {
  49. String currStr = in.next();
  50. int len = currStr.length();
  51. cntr = initValues[currStr.charAt(0) - 'a'];
  52. for (int i = 0; i < len-1; i++) {
  53. for (int j = i + 1; j < i + 2; j++) {
  54. char currChar = currStr.charAt(i);
  55. char nextChar = currStr.charAt(j);
  56. if(data[currChar-'a'][nextChar-'a']=='+'){
  57. cntr ++;
  58. }else if(data[currChar-'a'][nextChar-'a']=='-'){
  59. cntr --;
  60. }
  61. System.out.println(currChar + " " + nextChar);
  62. }
  63. }
  64.  
  65. System.out.println();
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement