-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix minor problem with highlighting in edit mode
- Loading branch information
1 parent
9458c37
commit f8cc770
Showing
10 changed files
with
413 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
resources/haystacks/0f48dc09-f725-4dd7-b1a7-b8654144f762.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<Haystack> | ||
<wheat>import java.util.Scanner;
 | ||

 | ||
public class Example {
 | ||
public static void main(String[] args) {
 | ||
Scanner s = new Scanner(System.in);
 | ||
String str = s.nextLine();
 | ||
if (str.isEmpty()) {
 | ||
System.out.println();
 | ||
return;
 | ||
}
 | ||
String[] mas = str.split(" ");
 | ||
int index = 0;
 | ||
while (index < mas.length) {
 | ||
System.out.print(mas[index]);
 | ||
System.out.print(" ");
 | ||
System.out.println(index);
 | ||
index = index + 1;
 | ||
}
 | ||
}
 | ||
}
 | ||
</wheat> | ||
<riddles> | ||
<riddle> | ||
<id>14ef1500-8eaa-450a-be53-96cf30489ddc</id> | ||
<needle>преобразование массива символов в строку</needle> | ||
<next/> | ||
<answer> | ||
<min>str.split(" ")</min> | ||
<max>String[] mas = str.split(" ");</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>b5474e40-99d3-4c4c-8680-4b19bede38a4</id> | ||
<needle>вывод на экран одного элемента массива</needle> | ||
<next/> | ||
<answer> | ||
<min>print(mas[index])</min> | ||
<max>System.out.print(mas[index]);</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>bab154ad-c57f-41f7-9355-12ec12e3a906</id> | ||
<needle>вывод на экран индекса элемента</needle> | ||
<next/> | ||
<answer> | ||
<min>println(index</min> | ||
<max>System.out.println(index);</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>b3185a4f-8ae4-4ae1-a40d-a2d1e64f3fb4</id> | ||
<needle>объявление переменной, обозначающей индекс</needle> | ||
<next/> | ||
<answer> | ||
<min>int index</min> | ||
<max>int index = 0;</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>3f0d0f42-4e74-481a-a9d7-812a05f06179</id> | ||
<needle>выражение, обозначающее длину массива</needle> | ||
<next/> | ||
<answer> | ||
<min>mas.length</min> | ||
<max>mas.length</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>4ddebb87-ebf3-4885-8205-13ed15d7afea</id> | ||
<needle>сравнение счетчика с длиной массива</needle> | ||
<next/> | ||
<answer> | ||
<min>index < mas.length</min> | ||
<max>while (index < mas.length) {</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>444f6927-64d5-4782-b4c6-50a3097624a6</id> | ||
<needle>команды для проверки исходных данных</needle> | ||
<next/> | ||
<answer> | ||
<min>if (str.isEmpty()) { System.out.println(); return; }</min> | ||
<max>if (str.isEmpty()) { System.out.println(); return; }</max> | ||
</answer> | ||
</riddle> | ||
</riddles> | ||
</Haystack> |
111 changes: 111 additions & 0 deletions
111
resources/haystacks/4eab8f11-7dc5-4f8e-9174-eec89eccf240.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<Haystack> | ||
<wheat>import java.util.Scanner;
 | ||

 | ||
public class Example {
 | ||
public static void main(String[] args) {
 | ||
Scanner s = new Scanner(System.in);
 | ||
String data = s.nextLine();
 | ||
int a = s.nextInt();
 | ||
if (data.isEmpty()) {
 | ||
System.out.println("Исходная строка пуста");
 | ||
return;
 | ||
}
 | ||
String[] arr = data.split(" ");
 | ||
if (a < 0 || arr.length <= a) {
 | ||
System.out.println("Число A должно быть в интервале [0, размер массива)");
 | ||
return;
 | ||
}
 | ||
System.out.println("В массиве длиной " + arr.length);
 | ||
System.out.println("на индексе " + a);
 | ||
System.out.println("находится элемент со значением " + arr[a]);
 | ||
}
 | ||
}
 | ||
</wheat> | ||
<riddles> | ||
<riddle> | ||
<id>85a1129d-1d7f-4d05-be5d-459b5d797e28</id> | ||
<needle>команда для получения текста от пользователя</needle> | ||
<next/> | ||
<answer> | ||
<min>s.nextLine()</min> | ||
<max>String data = s.nextLine();</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>ebfa3102-6cf6-4a25-ae15-844f452285fe</id> | ||
<needle>команда для получения числа от пользователя</needle> | ||
<next/> | ||
<answer> | ||
<min>s.nextInt()</min> | ||
<max>int a = s.nextInt();</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>e757d909-201f-4f6b-9c5b-b524378cd9ed</id> | ||
<needle>команда преобразования строки в массив</needle> | ||
<next/> | ||
<answer> | ||
<min>data.split(" ")</min> | ||
<max>String[] arr = data.split(" ");</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>b4c12bd5-2021-460c-8b7f-955002fc2e18</id> | ||
<needle>выражение, которое обозначает длину массива</needle> | ||
<next/> | ||
<answer> | ||
<min>arr.length</min> | ||
<max>arr.length</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>f22c4a83-3273-4783-bbed-5bf330a5bafa</id> | ||
<needle>выражение, которое обозначает элемент массива на индексе "a"</needle> | ||
<next/> | ||
<answer> | ||
<min>arr[a]</min> | ||
<max>arr[a]</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>46fda5d0-0e89-4266-8a0e-1b7e6a4d243b</id> | ||
<needle>команду для вывода на экран элемента массива arr</needle> | ||
<next/> | ||
<answer> | ||
<min>System.out.println("находится элемент со значением " + arr[a])</min> | ||
<max>System.out.println("находится элемент со значением " + arr[a]);</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>14133d6a-8433-4c22-9868-20708c8f4350</id> | ||
<needle>команду для вывода на экран длины массива</needle> | ||
<next/> | ||
<answer> | ||
<min>System.out.println("В массиве длиной " + arr.length);</min> | ||
<max>System.out.println("В массиве длиной " + arr.length);</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>ba24e404-0990-41cf-8b4c-28dda5df6909</id> | ||
<needle>сравнение переменной и длины массива</needle> | ||
<next/> | ||
<answer> | ||
<min>arr.length <= a</min> | ||
<max>if (a < 0 || arr.length <= a) {</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>1fdc9ea6-d4cb-48f2-a75b-421fff9b07fa</id> | ||
<needle>проверку исходных данных</needle> | ||
<next/> | ||
<answer> | ||
<min>a < 0 || arr.length <= a</min> | ||
<max>if (a < 0 || arr.length <= a) { System.out.println("Число A должно быть в интервале [0, размер массива)"); return; }</max> | ||
</answer> | ||
<answer> | ||
<min>data.isEmpty()</min> | ||
<max>if (data.isEmpty()) { System.out.println("Исходная строка пуста"); return; }</max> | ||
</answer> | ||
</riddle> | ||
</riddles> | ||
</Haystack> |
124 changes: 124 additions & 0 deletions
124
resources/haystacks/640b01f4-1db4-46f0-9dd2-6c4058b380f2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<Haystack> | ||
<wheat>import java.util.Scanner;
 | ||

 | ||
public class Example {
 | ||
public static void main(String[] args) {
 | ||
Scanner s = new Scanner(System.in);
 | ||
String data = s.nextLine();
 | ||
if (data.isEmpty()) {
 | ||
System.out.println("Исходная строка пуста");
 | ||
return;
 | ||
}
 | ||
String[] arr = data.split(" ");
 | ||

 | ||
int lastIndex = arr.length - 1;
 | ||
System.out.println("Индекс последнего элемента " + lastIndex);
 | ||
System.out.println("Значение последнего элемента " + arr[lastIndex]);
 | ||
System.out.println("Вместо " + arr[0] + " пишем " + arr[lastIndex]);
 | ||
arr[0] = arr[lastIndex];
 | ||
System.out.println("Элементы массива:");
 | ||
int i = 0;
 | ||
while (i < arr.length) {
 | ||
System.out.print(arr[i] + " ");
 | ||
i = i + 1;
 | ||
}
 | ||
}
 | ||
}
 | ||
</wheat> | ||
<riddles> | ||
<riddle> | ||
<id>d4a667a6-c09f-4afb-8806-444a805c8de3</id> | ||
<needle>команду для преобразования строки в массив</needle> | ||
<next/> | ||
<answer> | ||
<min>data.split(" ")</min> | ||
<max>String[] arr = data.split(" ");</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>090a5ff0-e6e1-4012-9640-b2b034864b8c</id> | ||
<needle>команду для получения текста от пользователя</needle> | ||
<next/> | ||
<answer> | ||
<min>s.nextLine()</min> | ||
<max>String data = s.nextLine();</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>2a492905-bb70-467f-b60b-bb8922191ca4</id> | ||
<needle>выражение, которое обозначает длину массива</needle> | ||
<next/> | ||
<answer> | ||
<min>arr.length</min> | ||
<max>arr.length</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>f4f6aa83-74fb-46b8-baee-549cd90c3486</id> | ||
<needle>выражение, которое обозначает "элемент массива на индексе 0"</needle> | ||
<next/> | ||
<answer> | ||
<min>arr[0]</min> | ||
<max>arr[0]</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>018c810a-a7d8-405c-882c-5f31a02bb084</id> | ||
<needle>вычисление индекса последнего элемента массива</needle> | ||
<next/> | ||
<answer> | ||
<min>arr.length - 1</min> | ||
<max>int lastIndex = arr.length - 1;</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>cd248f22-be8e-4e20-8f23-7e395bb356d7</id> | ||
<needle>выражение, которое обозначает "элемент массива на последнем индексе"</needle> | ||
<next/> | ||
<answer> | ||
<min>arr[lastIndex]</min> | ||
<max>arr[lastIndex]</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>70dee3b2-bc60-4760-a461-19f1fad5f6e7</id> | ||
<needle>команды для вывода всех элементов массива на экран</needle> | ||
<next/> | ||
<answer> | ||
<min>while (i < arr.length) { System.out.print(arr[i] + " "); i = i + 1; }</min> | ||
<max>int i = 0; while (i < arr.length) { System.out.print(arr[i] + " "); i = i + 1; }</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>32a15588-bc79-4604-8027-8c0ee29be249</id> | ||
<needle>команду для вывода на экран значения последнего элемента массива</needle> | ||
<next/> | ||
<answer> | ||
<min>System.out.println("Значение последнего элемента " + arr[lastIndex]);</min> | ||
<max>System.out.println("Значение последнего элемента " + arr[lastIndex]);</max> | ||
</answer> | ||
<answer> | ||
<min>System.out.println("Вместо " + arr[0] + " пишем " + arr[lastIndex]);</min> | ||
<max>System.out.println("Вместо " + arr[0] + " пишем " + arr[lastIndex]);</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>8df1bb13-167e-4388-8438-e81fe9d7deb8</id> | ||
<needle>команду для вывода на экран начального элемента массива</needle> | ||
<next/> | ||
<answer> | ||
<min>System.out.println("Вместо " + arr[0] + " пишем " + arr[lastIndex]);</min> | ||
<max>System.out.println("Вместо " + arr[0] + " пишем " + arr[lastIndex]);</max> | ||
</answer> | ||
</riddle> | ||
<riddle> | ||
<id>f7ac6373-6a6e-4996-add2-7f7f7805b99d</id> | ||
<needle>запись значения из последнего элемента массива в нулевой</needle> | ||
<next/> | ||
<answer> | ||
<min>arr[0] = arr[lastIndex];</min> | ||
<max>arr[0] = arr[lastIndex];</max> | ||
</answer> | ||
</riddle> | ||
</riddles> | ||
</Haystack> |
Oops, something went wrong.