Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //стр.6 main
- //стр.40 reverse
- //стр.49 println
- package hate;
- public class Main {
- public static void main(String[] args) {
- String text = "задачч";
- String check = "даччаз";
- if (text.length() == check.length()) {
- String cipherStart = "";
- boolean tf = false;
- int index = 0;
- for (int i = 1; i < check.length(); i++) {
- cipherStart = (String) check.subSequence(0, i);
- if (text.contains(cipherStart)) {
- tf= true;
- index++;
- }
- }
- cipherStart = (String) check.subSequence(0, index);
- if (tf) {
- String cipherOver = "";
- cipherOver = (String) text.subSequence(0, text.length()-index);
- String cipherHave = cipherStart + reverse(cipherOver);
- println(cipherHave);
- if (cipherHave.equals(check))
- println("YES");
- else
- println("NO");
- }
- }
- else
- println("NO");
- }
- public static String reverse (String necessary){
- String overReverse = "";
- for(int i = necessary.length()-1;i >= 0;i--){
- overReverse += necessary.charAt(i);
- }
- return overReverse;
- }
- public static void println(String output){
- System.out.println(output);
- }
- }
Add Comment
Please, Sign In to add comment