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
8 changes: 7 additions & 1 deletion task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public static void main(String[] args) throws IOException {

public static int checkSumOfStream(InputStream inputStream) throws IOException {
// your implementation here
return 0;
if (inputStream == null)
throw new IllegalArgumentException();
int sum = 0;
int value;
while ((value = inputStream.read()) != -1)
sum = Integer.rotateLeft(sum, 1) ^ value;
return sum;
}
}
9 changes: 9 additions & 0 deletions task02/src/com/example/task02/Task02Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ public static void main(String[] args) throws IOException {
// - направить стандартный вывод программы в файл output.test
// - запустить программу
// - и сравнить получившийся файл output.test с expected.test
int first = System.in.read();
int second;
while (first != -1){
second = System.in.read();
if (!(first == 13 & second == 10))
System.out.write(first);
first = second;
}
System.out.flush();
}
}
6 changes: 5 additions & 1 deletion task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.example.task03;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

public class Task03Main {
Expand All @@ -16,6 +18,8 @@ public static void main(String[] args) throws IOException {

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

import java.io.IOException;
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 scanner = new Scanner(System.in).useLocale(Locale.US);
double result = 0;
while (scanner.hasNextDouble())
result += scanner.nextDouble();
System.out.printf(scanner.locale(), "%.6f", result);
//System.err.println("0.0");
}
}