Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit f4c460e

Browse files
committed
123 132 312 321 231 213 <- fun one
1 parent 495c46b commit f4c460e

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

students/23K0341/23K0341-p32/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>23K0341</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0341-p32</artifactId>
12+
<description>Второе задание</description>
13+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
public final class Main {
4+
5+
private Main() {
6+
7+
}
8+
9+
public static void main(String[] args) {
10+
System.out.println("вторая практическая работа!");
11+
}
12+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.Arrays;
4+
5+
/**
6+
* Задание 1 Реализовать алгоритма генерации перестановок
7+
* Джонсона-Троттера:<br>
8+
* Описание алгоритма<br>
9+
*  На русском яз. + псевдокод:
10+
* <a href="https://books.google.ru/books?id=HIaf7DSPtl0C&pg=PA228&lpg=PA228&dq=алгоритм+джонсона+троттера&source=bl&ots=YOhS_RzlkF&sig=754ZHiufVsdeiLr8fxQpuSsHjaU&hl=ru&sa=X&sqi=2&ved=0ahUKEwjxo83l5ffTAhVsJ5oKHTasBSYQ6AEINDAC#v=onepage&q=алгоритм%20джонсона%20троттера&f=false">...</a><br>
11+
*  На англ.яз с картинками- понятно:
12+
* <a href="https://mathlesstraveled.com/2013/01/03/the-steinhaus-johnson-trotter-algorithm/">...</a><br>
13+
* Учебное пособие можно взять здесь
14+
* <a href="http://fit.nsu.ru/data_/courses/niu/daio_komb_alg_uchpos.pdf">...</a>
15+
*/
16+
17+
public abstract class Task {
18+
static void cycle(int[] data, int moving) {
19+
for (int i = data.length - 1; i > (moving > 0 ? 0 : 1); i--) {
20+
System.out.println(Arrays.toString(data));
21+
int temp = data[i - 1];
22+
data[i - 1] = data[i];
23+
data[i] = temp;
24+
}
25+
}
26+
27+
public static void main(String[] args) {
28+
int len = 4;
29+
int[] data = new int[len];
30+
31+
for (int i = 0; i < len; i++) {
32+
data[i] = i + 1;
33+
}
34+
35+
for (int i = 0; i < len; i++) {
36+
cycle(data, len - 1 - i);
37+
}
38+
System.out.println(Arrays.toString(data));
39+
}
40+
}

0 commit comments

Comments
 (0)