Answer the question
In order to leave comments, you need to log in
JAVA. Where to begin?
The text of n2 characters is encrypted according to the following rule: - all characters of the text are written in a square table of dimension n in order from left to right, top to bottom; - the table rotates 90° clockwise; - 1st row of the table is swapped with the last one, 2nd - with the penultimate one, etc. -1st column of the table is swapped with the 2nd, 3rd - with the 4th, etc. - encrypted the text is obtained by traversing the resulting table in a clockwise spiral, starting from the upper left corner. Encrypt the text according to the specified rule. ps I did a root extraction check and got stuck.
import java.util.Scanner;
public class number4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Введите текст: ");
String str = in.nextLine();
int dg = str.length();
double sqr = Math.sqrt(dg);
if (Math.round(Math.sqrt(dg)) * Math.round(Math.sqrt(dg)) == dg){
}
else {
System.out.println("Не удовлетворяет условию задачи.");
}
}
}
Answer the question
In order to leave comments, you need to log in
and on a horse-radish to you extraction of a root??
according to the conditions, you are not given a string of arbitrary length, which you are trying to get from the user in the presented algorithm, but a string of a predetermined length.
rewrite under the conditions ...
the task is cool, it even allows you to separate smart coders from stubborn ones :)
The meaning of this problem is similar to the Square of Polybius. The author can google for this keyword and find ready-made implementations. But it seems to me that the author still has much more gaps in skills. You need to be skilled at writing nested loops.
That is to practice on simple tasks.
And this difficult task or even to postpone until. Or split into a sequence of elementary ones. I don't know how to break. The author must come up with this for himself based on his understanding of the steps.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question