Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.task01;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

Expand All @@ -8,14 +9,18 @@ public static void main(String[] args) throws IOException {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:

/*
System.out.println(checkSumOfStream(new ByteArrayInputStream(new byte[]{0x33, 0x45, 0x01})));
*/

}

public static int checkSumOfStream(InputStream inputStream) throws IOException {
// your implementation here
return 0;
public static int checkSumOfStream(InputStream inputStream) throws IOException, IllegalArgumentException {
if (inputStream == null) { throw new IllegalArgumentException(); }

int checkSum = 0;
int i;
while ((i = inputStream.read()) != -1) {
checkSum = Integer.rotateLeft(checkSum, 1) ^ (byte)i;
}
return checkSum;
}
}
13 changes: 12 additions & 1 deletion task02/src/com/example/task02/Task02Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.task02;

import java.io.IOException;
import java.io.*;
import java.nio.file.Path;
import java.util.Scanner;

public class Task02Main {
public static void main(String[] args) throws IOException {
Expand All @@ -9,5 +11,14 @@ public static void main(String[] args) throws IOException {
// - направить стандартный вывод программы в файл output.test
// - запустить программу
// - и сравнить получившийся файл output.test с expected.test
int a = System.in.read();
while (a != -1) {
int b = System.in.read();
if (!(a == 13 & b == 10)) {
System.out.write(a);
}
a = b;
}
System.out.flush();
}
}
20 changes: 20 additions & 0 deletions task02/src/com/example/task02/output.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
> Task :task02:compileJava UP-TO-DATE
> Task :task02:processResources NO-SOURCE
> Task :task02:classes UP-TO-DATE
> Task :task02:Task02Main.main() FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':task02:Task02Main.main()'.
> Build cancelled while executing task ':task02:Task02Main.main()'

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s
2 actionable tasks: 1 executed, 1 up-to-date
12 changes: 6 additions & 6 deletions task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package com.example.task03;

import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;

public class Task03Main {
public static void main(String[] args) throws IOException {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:

/*
System.out.println(readAsString(new FileInputStream("task03/src/com/example/task03/input.test"), Charset.forName("KOI8-R")));
*/
}

public static String readAsString(InputStream inputStream, Charset charset) throws IOException {
// your implementation here
return "";
if (inputStream == null || !charset.isRegistered()) { throw new IllegalArgumentException(); }
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, charset));
return reader.readLine();
}
}
18 changes: 16 additions & 2 deletions task04/src/com/example/task04/Task04Main.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
package com.example.task04;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Locale;
import java.util.Scanner;

public class Task04Main {
public static void main(String[] args) throws IOException {
// чтобы протестировать свое решение, вам нужно:
// - направить файл input.test в стандартный ввод программы (в настройках запуска программы в IDE или в консоли)
// - запустить программу
// - проверить, что получилось 351.731900

System.out.println("0.0");
Scanner in = new Scanner(System.in);
double sum = 0;
while (in.hasNext()) {
try {
sum += Double.parseDouble(in.next());
} catch (Exception e) {
}
}
System.out.printf(Locale.US,"%.6f", sum);
}

}