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
11 changes: 9 additions & 2 deletions task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ 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 = 0;
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();
}
}
11 changes: 7 additions & 4 deletions task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.task03;

import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.nio.charset.Charset;

public class Task03Main {
Expand All @@ -15,7 +14,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.isSupported(charset.toString()))
throw new IllegalArgumentException();

BufferedReader buffer = new BufferedReader(new InputStreamReader(inputStream, charset));
return buffer.readLine();
}
}
16 changes: 14 additions & 2 deletions task04/src/com/example/task04/Task04Main.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
package com.example.task04;

import java.io.IOException;
import java.util.InputMismatchException;
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 sum = 0;
while (scanner.hasNext()) {
try {
double i = scanner.nextDouble();
sum += i;
} catch (InputMismatchException e) {
scanner.next();
}
}
System.out.printf(scanner.locale(), "%.6f\n", sum);
}
}