EnGold

Шифр есть? А если найду?

May 3rd, 2021 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. //стр.6 main
  2. //стр.40 reverse
  3. //стр.49 println
  4. package hate;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. String text = "задачч";
  10. String check = "даччаз";
  11. if (text.length() == check.length()) {
  12. String cipherStart = "";
  13. boolean tf = false;
  14. int index = 0;
  15. for (int i = 1; i < check.length(); i++) {
  16. cipherStart = (String) check.subSequence(0, i);
  17.  
  18. if (text.contains(cipherStart)) {
  19. tf= true;
  20. index++;
  21. }
  22. }
  23. cipherStart = (String) check.subSequence(0, index);
  24. if (tf) {
  25. String cipherOver = "";
  26. cipherOver = (String) text.subSequence(0, text.length()-index);
  27. String cipherHave = cipherStart + reverse(cipherOver);
  28. println(cipherHave);
  29. if (cipherHave.equals(check))
  30. println("YES");
  31. else
  32. println("NO");
  33. }
  34. }
  35. else
  36. println("NO");
  37. }
  38.  
  39.  
  40. public static String reverse (String necessary){
  41. String overReverse = "";
  42. for(int i = necessary.length()-1;i >= 0;i--){
  43. overReverse += necessary.charAt(i);
  44. }
  45. return overReverse;
  46. }
  47.  
  48.  
  49. public static void println(String output){
  50. System.out.println(output);
  51. }
  52. }
  53.  
Add Comment
Please, Sign In to add comment