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: 14 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,19 @@ 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 b = inputStream.read();
int checkSum = 0;

while (b > -1) {
checkSum = Integer.rotateLeft(checkSum, 1) ^ b;
b = inputStream.read();
}


return checkSum;
}
}
14 changes: 13 additions & 1 deletion task02/src/com/example/task02/Task02Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.task02;

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

public class Task02Main {
Expand All @@ -9,5 +9,17 @@ public static void main(String[] args) throws IOException {
// - направить стандартный вывод программы в файл output.test
// - запустить программу
// - и сравнить получившийся файл output.test с expected.test
InputStream inputStream = System.in;
int prev = inputStream.read();
int curr = inputStream.read();

while (prev != -1){
if(prev != 13 || curr != 10){
System.out.write(prev);
}
prev = curr;
curr = inputStream.read();
}
System.out.flush();
}
}
9 changes: 7 additions & 2 deletions task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.io.*;

public class Task03Main {
public static void main(String[] args) throws IOException {
Expand All @@ -15,7 +16,11 @@ 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 == null) {
throw new IllegalArgumentException();
}
Reader reader = new InputStreamReader(inputStream, charset);
BufferedReader bufferedReader = new BufferedReader(reader);
return bufferedReader.readLine();
}
}
16 changes: 11 additions & 5 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
Scanner scanner = new Scanner(System.in).useLocale(Locale.US);
double result = 0;
while (scanner.hasNextDouble()) {
double token = scanner.nextDouble();
result += token;
}

System.out.printf(Locale.US,"%.6f", result);


System.out.println("0.0");
}
}